HFST - Helsinki Finite-State Transducer Technology API  version 3.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HfstExceptionDefs.h
Go to the documentation of this file.
1 #ifndef _HFST_EXCEPTION_DEFS_H_
2 #define _HFST_EXCEPTION_DEFS_H_
3 
4 #include <string>
5 #include <sstream>
6 
7 void hfst_set_exception(std::string name);
8 std::string hfst_get_exception();
9 
12 
16 {
17  std::string name;
18  std::string file;
19  size_t line;
20  HfstException(void);
21  HfstException(const std::string &name,const std::string &file,size_t line);
23  std::string operator() (void) const;
24 };
25 
28 #define HFST_THROW(E) do { \
29  hfst_set_exception(std::string(#E)); \
30  throw E(#E,__FILE__,__LINE__); } \
31  while(false)
32 
35 #define HFST_THROW_MESSAGE(E,M) do { \
36  hfst_set_exception(std::string(#E)); \
37  throw E(std::string(#E)+": "+std::string(M) \
38  ,__FILE__,__LINE__); } \
39  while(false)
40 
42 #define HFST_EXCEPTION_CHILD_DECLARATION(CHILD) \
43  struct CHILD : public HfstException \
44  { CHILD(const std::string &name,const std::string &file,size_t line); }
45 
47 #define HFST_EXCEPTION_CHILD_DEFINITION(CHILD) \
48  CHILD::CHILD \
49  (const std::string &name,const std::string &file,size_t line):\
50  HfstException(name,file,line)\
51  {}
52 
54 #define HFST_CATCH(E) \
55  catch (const E &e) \
56  { \
57  std::cerr << e.file << ", line " << e.line << ": " << \
58  e() << std::endl; \
59  }
60 
61 // Example declaring an exception class SomeHfstException:
62 //HFST_EXCEPTION_CHILD_DECLARATION(SomeHfstException);
63 
64 
67 
81 
84 
101 
119 
141 
150 
169 
170 
196 
230 
231 HFST_EXCEPTION_CHILD_DECLARATION(NotValidPrologFormatException);
232 
233 HFST_EXCEPTION_CHILD_DECLARATION(NotValidLexcFormatException);
234 
251 
252 
253 
279 
280 
281 
282 
292 
305 
306 
314 
315 
325 
326 
348 
349 
350 
362 
363 
364 
365 /* \brief The type of a transducer is not specified.
366 
367  This exception is thrown when an ImplementationType argument
368  is ERROR_TYPE.
369 
370  @see hfst::ImplementationType
371  */
372 HFST_EXCEPTION_CHILD_DECLARATION(SpecifiedTypeRequiredException);
373 
374 
375 
376 
379 
380 
389 
396 
397 HFST_EXCEPTION_CHILD_DECLARATION(EmptyStringException);
398 
399 HFST_EXCEPTION_CHILD_DECLARATION(SymbolNotFoundException);
400 
401 //HFST_EXCEPTION_CHILD_DECLARATION(SymbolRedefinedException);
402 //HFST_EXCEPTION_CHILD_DECLARATION(TransducerHasNoStartStateException);
403 //HFST_EXCEPTION_CHILD_DECLARATION(TransducerHasMoreThanOneStartStateException);
404 
405 HFST_EXCEPTION_CHILD_DECLARATION(MetadataException);
406 
407 
408 #endif // #ifndef _HFST_EXCEPTION_DEFS_H_
std::string operator()(void) const
Get the error message.
Definition: HfstExceptionDefs.cc:20
The stream does not contain transducers.
Definition: HfstExceptionDefs.h:195
The library required by the implementation type requested is not linked to HFST.
Definition: HfstExceptionDefs.h:80
String is not valid utf-8.
Definition: HfstExceptionDefs.h:395
Context transducers are not automata.
Definition: HfstExceptionDefs.h:278
State is not final (and cannot have a final weight).
Definition: HfstExceptionDefs.h:250
An OpenFst transducer does not have an input symbol table.
Definition: HfstExceptionDefs.h:324
Base class for HfstExceptions. Holds its own name and the file and line number where it was thrown...
Definition: HfstExceptionDefs.h:15
Two or more transducers do not have the same type.
Definition: HfstExceptionDefs.h:347
The stream is at end.
Definition: HfstExceptionDefs.h:149
Two or more HfstTransducers are not of the same type.
Definition: HfstExceptionDefs.h:66
The StateId argument is not valid.
Definition: HfstExceptionDefs.h:304
The set of transducer pairs is empty.
Definition: HfstExceptionDefs.h:361
Transducers are not automata.
Definition: HfstExceptionDefs.h:291
Transducer is cyclic.
Definition: HfstExceptionDefs.h:168
An error happened probably due to a bug in the HFST code.
Definition: HfstExceptionDefs.h:378
Stream is closed.
Definition: HfstExceptionDefs.h:140
Stream cannot be read.
Definition: HfstExceptionDefs.h:100
Transducer has a malformed HFST header.
Definition: HfstExceptionDefs.h:313
#define HFST_EXCEPTION_CHILD_DECLARATION(CHILD)
Declare a subclass of HfstException of type CHILD.
Definition: HfstExceptionDefs.h:42
Stream cannot be written.
Definition: HfstExceptionDefs.h:118
Function has not been implemented (yet).
Definition: HfstExceptionDefs.h:83
The stream is not in valid AT&T format.
Definition: HfstExceptionDefs.h:229
Transducer has wrong type.
Definition: HfstExceptionDefs.h:388