27 #ifndef __mxException__
28 #define __mxException__
89 const std::string & emnem,
90 const std::string & efile,
92 const std::string & expl
101 const std::string & emnem,
103 const std::string & efile,
105 const std::string & expl
137 std::ostringstream s;
144 s <<
"\n code: " <<
m_code;
156 s <<
"\n " << strerror(
m_errno);
162 virtual const char *
what() const noexcept
177 const std::string & efile,
179 const std::string & expl
180 ) :
mxException(esrc, MXE_INVALIDARG,MXE_INVALIDARG_NAME, efile, line, expl)
193 const std::string & efile,
195 const std::string & expl
196 ) :
mxException(esrc, MXE_INVALIDCONFIG,MXE_INVALIDCONFIG_NAME, efile, line, expl)
209 const std::string & efile,
211 const std::string & expl
212 ) :
mxException(esrc, MXE_NOTIMPL,MXE_NOTIMPL_NAME, efile, line, expl)
225 const std::string & efile,
227 const std::string & expl
228 ) :
mxException(esrc, MXE_PARAMNOTSET,MXE_PARAMNOTSET_NAME, efile, line, expl)
241 const std::string & efile,
243 const std::string & expl
244 ) :
mxException(esrc, MXE_SIZEERR,MXE_SIZEERR_NAME, efile, line, expl)
257 const std::string & efile,
259 const std::string & expl
260 ) :
mxException(esrc, MXE_ALLOCERR,MXE_ALLOCERR_NAME, efile, line, expl)
273 const std::string & efile,
275 const std::string & expl
276 ) :
mxException(esrc, MXE_FILEOERR,MXE_FILEOERR_NAME, efile, line, expl)
281 const std::string & efile,
283 const std::string & expl
284 ) :
mxException(esrc, MXE_FILEOERR,MXE_FILEOERR_NAME, en, efile, line, expl)
297 const std::string & efile,
299 const std::string & expl
300 ) :
mxException(esrc, MXE_FILERERR,MXE_FILERERR_NAME, efile, line, expl)
305 const std::string & efile,
307 const std::string & expl
308 ) :
mxException(esrc, MXE_FILERERR,MXE_FILERERR_NAME, en, efile, line, expl)
321 const std::string & efile,
323 const std::string & expl
324 ) :
mxException(esrc, MXE_FILEWERR,MXE_FILEWERR_NAME, efile, line, expl)
329 const std::string & efile,
331 const std::string & expl
332 ) :
mxException(esrc, MXE_FILEWERR,MXE_FILEWERR_NAME, en, efile, line, expl)
345 const std::string & efile,
347 const std::string & expl
348 ) :
mxException(esrc, MXE_FILECERR,MXE_FILECERR_NAME, efile, line, expl)
353 const std::string & efile,
355 const std::string & expl
356 ) :
mxException(esrc, MXE_FILECERR,MXE_FILECERR_NAME, en, efile, line, expl)
369 const std::string & efile,
371 const std::string & expl
372 ) :
mxException(esrc, MXE_LIBERR,MXE_LIBERR_NAME, efile, line, expl)
380 #define mxThrowException( extype, src, expl ) throw extype(src, __FILE__, __LINE__, expl);
382 #define mxThrowExceptionErrno( extype, en, src, expl ) throw extype(src, en, __FILE__, __LINE__, expl);
mxException for an allocation error
allocerr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
mxException for errors closing a file
filecerr(const std::string &esrc, const int &en, const std::string &efile, const int &line, const std::string &expl)
filecerr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
mxException for errors on opening a file
fileoerr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
fileoerr(const std::string &esrc, const int &en, const std::string &efile, const int &line, const std::string &expl)
mxException for errors reading from a file
filererr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
filererr(const std::string &esrc, const int &en, const std::string &efile, const int &line, const std::string &expl)
mxException for errors writing to a file
filewerr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
filewerr(const std::string &esrc, const int &en, const std::string &efile, const int &line, const std::string &expl)
mxException for invalid arguments
invalidarg(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
mxException for invalid config settings
invalidconfig(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
mxException for errors returned by a library call
liberr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
The mxlib exception class.
virtual const char * what() const noexcept
Return the details of the exception as a single string.
std::string m_file
The source file where the exception originated.
std::string m_source
The source of the exception, such as stdlib or cfitisio or the function name.
mxException(const std::string &esrc, const int &ec, const std::string &emnem, const int &en, const std::string &efile, const int &line, const std::string &expl)
Construct and fill in each of the values, including errno.
mxException(const mxException &e) noexcept
Copy constructor.
int m_line
The line number of the file where the exception originated.
std::string m_codeName
The name of the error code.
char m_whatstr[4096]
Contains the what() string.
mxException(const std::string &esrc, const int &ec, const std::string &emnem, const std::string &efile, const int &line, const std::string &expl)
Construct and fill in each of the values, except errno.
virtual ~mxException()
Destructor.
int m_errno
The errno error code (only used if non-zero)
std::string m_explanation
The long explanation of the error.
int m_code
The mxlib error code.
mxException & operator=(const mxException &e) noexcept
Assignment operator.
virtual void build_what()
Build the what string.
mxException() noexcept
Default constructor.
mxException for not implemented features
notimpl(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
mxException for parameters which aren't set
paramnotset(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
mxException for a size error
sizeerr(const std::string &esrc, const std::string &efile, const int &line, const std::string &expl)
std::string errno_CodeToName(int ec)
Return the macro name and a message for a standard errno code.
Declares and defines the mxlib error reporting system.