Evo C++ Library v0.5.1
Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
Exception Class Reference

#include <evo/impl/sys.h>

Inheritance diagram for Exception:
Inheritance graph
[legend]

Detailed Description

Evo base exception class.

Public Types

typedef ListBase< char, StrSizeTStringBase
 Alias for evo::StringBase. More...
 

Public Member Functions

 Exception (const char *file, ulong line, const StringBase &msg, Error error=EUnknown)
 Constructor with file/line info. More...
 
 Exception (const Exception &e)
 Copy constructor. More...
 
 ~Exception ()
 Destructor. More...
 
Error error () const
 Get error code. More...
 
template<class TOut >
TOut & errormsg_out (TOut &out)
 Write error message with errno to output stream/string. More...
 
const char * file () const
 Get exception file name. More...
 
ulong line () const
 Get exception line number. More...
 
const char * msg () const
 Get exception message. More...
 

Protected Types

typedef const char *(* ErrorMsgFunc) (Error)
 Pointer type to function returning error message from error code. More...
 

Protected Member Functions

 Exception (const char *file, ulong line, const char *type, const StringBase &msg, Error error, ErrorMsgFunc errmsg_func)
 Constructor with exception type. More...
 

Member Typedef Documentation

◆ ErrorMsgFunc

typedef const char*(* ErrorMsgFunc) (Error)
protected

Pointer type to function returning error message from error code.

◆ StringBase

typedef ListBase<char,StrSizeT> StringBase

Alias for evo::StringBase.

Constructor & Destructor Documentation

◆ Exception() [1/3]

Exception ( const char *  file,
ulong  line,
const StringBase msg,
Error  error = EUnknown 
)
inline

Constructor with file/line info.

Parameters
fileException file name (use FILE macro)
lineException line number (use LINE macro)
msgException message
errorError code, EUnknown if unknown

◆ Exception() [2/3]

Exception ( const Exception e)
inline

Copy constructor.

Parameters
eException to copy

◆ ~Exception()

~Exception ( )
inline

Destructor.

◆ Exception() [3/3]

Exception ( const char *  file,
ulong  line,
const char *  type,
const StringBase msg,
Error  error,
ErrorMsgFunc  errmsg_func 
)
inlineprotected

Constructor with exception type.

Use EVO_THROW() or EVO_THROW_E() macro to throw exception.

Parameters
fileException file name
lineException line number
typeException type as string, used as msg prefix
msgException message
errorError code, EUnknown if unknown
errmsg_funcError message function to use

Member Function Documentation

◆ error()

Error error ( ) const
inline

Get error code.

Returns
Error code, 0 if unknown

◆ errormsg_out()

TOut& errormsg_out ( TOut &  out)
inline

Write error message with errno to output stream/string.

  • Must call right after the error, otherwise errno may be overwritten
Template Parameters
TOutOutput stream or string type
Parameters
outStream or String to write output to
Returns
This

◆ file()

const char* file ( ) const
inline

Get exception file name.

Returns
File name

◆ line()

ulong line ( ) const
inline

Get exception line number.

Returns
Line number

◆ msg()

const char* msg ( ) const
inline

Get exception message.

Returns
Message

The documentation for this class was generated from the following file: