EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
GenericException.h
1 // -*- c++ -*-
2 
3 #ifndef _GENERICEXCEPTION_H_
4 #define _GENERICEXCEPTION_H_
5 
6 #include <cstdlib>
7 #include <cstdarg>
8 
9 // #include "tools/ToolsConfig.h"
10 #include <string>
11 
12 #ifdef USE_STD_EXCEPTION
13 #include <exception>
14 #endif
15 
17 
44 
46 #ifdef USE_STD_EXCEPTION
47  : public std::exception
48 #endif
49 {
50 public:
51 
53  GenericException(const char *sourcefile, size_t line)
54  : sourcefile(sourcefile), line(line)
55  {}
56 
58  GenericException(const char *sourcefile, size_t line,
59  const char *format, ...)
60  __attribute__ ((format (printf, 4, 5)));
61 
62  // Strange but true, __attribute__ format seems to include
63  // an initial 'this' argument in the position count.
64 
66  virtual ~GenericException() throw () {}
67 
70  virtual const char* what() const throw ();
71 
73  const char* getSourceFile() const
74  { return sourcefile; }
75 
77  size_t getSourceLine() const
78  { return line; }
79 
81  const std::string& getDetail () const
82  { return detail; }
83 
84 protected:
85 
88  mutable std::string error_info;
89 
91  mutable std::string detail;
92 
95  const char *sprintf(std::string &s, const char *format, ...) const throw ();
96 
99  const char *sprintf(std::string &s, const char *format, va_list ap) const throw ()
100  __attribute__ ((format (printf, 3, 0)));
101 
102 private:
103 
104  const char *sourcefile;
105  size_t line;
106 
107 };
108 
109 #endif // !defined(_GENERICEXCEPTION_H_)
110 
GenericException(const char *sourcefile, size_t line)
Construct with file and line info.
Definition: GenericException.h:53
const char * getSourceFile() const
Source file where exception was thrown.
Definition: GenericException.h:73
size_t getSourceLine() const
Line in source file where exception was thrown.
Definition: GenericException.h:77
Generic Exception: Base class for exceptions.
Definition: GenericException.h:45
const std::string & getDetail() const
Return detail text (if set)
Definition: GenericException.h:81
virtual const char * what() const
Retrieve an explanatory string.