HFST - Helsinki Finite-State Transducer Technology - C++ API  version 3.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HfstExceptionDefs.h
Go to the documentation of this file.
1 // Copyright (c) 2016 University of Helsinki
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 3 of the License, or (at your option) any later version.
7 // See the file COPYING included with this distribution for more
8 // information.
9 
10 #ifndef _HFST_EXCEPTION_DEFS_H_
11 #define _HFST_EXCEPTION_DEFS_H_
12 
13 #include <string>
14 #include <sstream>
15 
16 void hfst_set_exception(std::string name);
17 std::string hfst_get_exception();
18 
19 #include "hfstdll.h"
20 
23 
27 {
28  std::string name;
29  std::string file;
30  size_t line;
31  HfstException(void);
32  HfstException(const std::string &name,const std::string &file,size_t line);
33  ~HfstException();
35  HFSTDLL std::string operator() (void) const;
36 };
37 
40 #define HFST_THROW(E) do { \
41  hfst_set_exception(std::string(#E)); \
42  throw E(#E,__FILE__,__LINE__); } \
43  while(false)
44 
47 #define HFST_THROW_MESSAGE(E,M) do { \
48  hfst_set_exception(std::string(#E)); \
49  throw E(std::string(#E)+": "+std::string(M) \
50  ,__FILE__,__LINE__); } \
51  while(false)
52 
54 #define HFST_EXCEPTION_CHILD_DECLARATION(CHILD) \
55  struct CHILD : public HfstException \
56  { CHILD(const std::string &name,const std::string &file,size_t line); }
57 
59 #define HFST_EXCEPTION_CHILD_DEFINITION(CHILD) \
60  CHILD::CHILD \
61  (const std::string &name,const std::string &file,size_t line):\
62  HfstException(name,file,line)\
63  {}
64 
66 #define HFST_CATCH(E) \
67  catch (const E &e) \
68  { \
69  std::cerr << e.file << ", line " << e.line << ": " << \
70  e() << std::endl; \
71  }
72 
73 // Example declaring an exception class SomeHfstException:
74 //HFST_EXCEPTION_CHILD_DECLARATION(SomeHfstException);
75 
76 
79 
93 
96 
113 
131 
153 
162 
181 
182 
208 
242 
243 HFST_EXCEPTION_CHILD_DECLARATION(NotValidPrologFormatException);
244 
245 HFST_EXCEPTION_CHILD_DECLARATION(NotValidLexcFormatException);
246 
263 
264 
265 
291 
292 
293 
294 
304 
317 
318 
326 
327 
337 
338 
360 
361 
362 
374 
375 
376 
377 /* \brief The type of a transducer is not specified.
378 
379  This exception is thrown when an ImplementationType argument
380  is ERROR_TYPE.
381 
382  @see hfst::ImplementationType
383  */
384 HFST_EXCEPTION_CHILD_DECLARATION(SpecifiedTypeRequiredException);
385 
386 
387 
388 
391 
392 
401 
408 
409 HFST_EXCEPTION_CHILD_DECLARATION(EmptyStringException);
410 
411 HFST_EXCEPTION_CHILD_DECLARATION(SymbolNotFoundException);
412 
413 HFST_EXCEPTION_CHILD_DECLARATION(FlagDiacriticsAreNotIdentitiesException);
414 
415 //HFST_EXCEPTION_CHILD_DECLARATION(SymbolRedefinedException);
416 //HFST_EXCEPTION_CHILD_DECLARATION(TransducerHasNoStartStateException);
417 //HFST_EXCEPTION_CHILD_DECLARATION(TransducerHasMoreThanOneStartStateException);
418 
419 HFST_EXCEPTION_CHILD_DECLARATION(MetadataException);
420 
421 
422 #endif // #ifndef _HFST_EXCEPTION_DEFS_H_
HFSTDLL std::string operator()(void) const
Get the error message.
Definition: HfstExceptionDefs.cc:31
The stream does not contain transducers.
Definition: HfstExceptionDefs.h:207
The library required by the implementation type requested is not linked to HFST.
Definition: HfstExceptionDefs.h:92
String is not valid utf-8.
Definition: HfstExceptionDefs.h:407
Context transducers are not automata.
Definition: HfstExceptionDefs.h:290
State is not final (and cannot have a final weight).
Definition: HfstExceptionDefs.h:262
An OpenFst transducer does not have an input symbol table.
Definition: HfstExceptionDefs.h:336
Base class for HfstExceptions. Holds its own name and the file and line number where it was thrown...
Definition: HfstExceptionDefs.h:26
Two or more transducers do not have the same type.
Definition: HfstExceptionDefs.h:359
The stream is at end.
Definition: HfstExceptionDefs.h:161
Two or more HfstTransducers are not of the same type.
Definition: HfstExceptionDefs.h:78
The StateId argument is not valid.
Definition: HfstExceptionDefs.h:316
The set of transducer pairs is empty.
Definition: HfstExceptionDefs.h:373
Transducers are not automata.
Definition: HfstExceptionDefs.h:303
Transducer is cyclic.
Definition: HfstExceptionDefs.h:180
An error happened probably due to a bug in the HFST code.
Definition: HfstExceptionDefs.h:390
Stream is closed.
Definition: HfstExceptionDefs.h:152
Stream cannot be read.
Definition: HfstExceptionDefs.h:112
Transducer has a malformed HFST header.
Definition: HfstExceptionDefs.h:325
#define HFST_EXCEPTION_CHILD_DECLARATION(CHILD)
Declare a subclass of HfstException of type CHILD.
Definition: HfstExceptionDefs.h:54
Stream cannot be written.
Definition: HfstExceptionDefs.h:130
Function has not been implemented (yet).
Definition: HfstExceptionDefs.h:95
The stream is not in valid AT&T format.
Definition: HfstExceptionDefs.h:241
Transducer has wrong type.
Definition: HfstExceptionDefs.h:400