Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
Loading...
Searching...
No Matches
Exceptions

Description


Enhancing run-time errors with two kinds of them: Exceptions (critical errors to be produced only while debugging code) and Errors (to be produced in production to indicate something to the user).

Note
- To use this system, you must define ELE_PRE_TRACED at the beginning of your .cpp, before including the debugging.h header, as explained there.
- This very header must be included after the inclusion of debugging.h.
See also
Debugging of code
Author
Juan-Antonio Fernandez-Madrigal. http://jafma.net
Date
2018-2022
Collaboration diagram for Exceptions:

Classes

class  elementa::base::Exc
 Base class for all errors / exceptions in Elementa. Just derive from it. More...
 
class  elementa::base::unimplemented
 Exception for indicating in runtime that a section of code is unimplemented. More...
 
class  elementa::base::todo
 Exception for indicating in runtime that a section of code is TODO. More...
 
class  elementa::base::notreach
 Exception for indicating in runtime that a code should not be reached. More...
 
class  elementa::base::invstate
 Exception for indicating that some object is in invalid state. More...
 
class  elementa::base::internal_error
 Exception for indicating some internal error not caused by user of object. More...
 
class  elementa::base::notfound
 Exception for indicating that some element has not been found in some place. More...
 
class  elementa::base::invarg
 Exception for indicating that some argument of a method/function is invalid. More...
 
class  elementa::base::outofrange
 Exception for indicating that some value is out of range. More...
 

Macros

#define ELE_CLASS_EXCOVERRIDE(C)
 Shortening macro that must be used inside classes derived from Exc. More...
 
#define ELE_CODE_UNIMPLEMENTED
 To throw an unimplemented exception. More...
 
#define ELE_CODE_TODO(expl)
 To throw a TODO exception. More...
 
#define ELE_CODE_NOTREACH
 To throw a should-not-reach-here exception. More...
 
#define ELE_CODE_INTERNALERR(expl)
 To throw an internal-error exception with an explanation. More...
 
#define ELE_CODE_INVSTATE(expl)
 To throw an invalid-state exception with an explanation.
More...
 
#define ELE_CODE_INVARG(expl)
 To throw an invalid-argument exception with an explanation. More...
 
#define ELE_CODE_OUTOFRANGE(expl)
 To throw an out-of-range exception with an explanation.
More...
 
#define ELE_CODE_NOTFOUND(expl)
 To throw a not-found exception with an explanation.
More...
 

Class Documentation

◆ elementa::base::Exc

class elementa::base::Exc

Base class for all errors / exceptions in Elementa. Just derive from it.

The mandatory data contained in an exception is the explanation (string), and, if thrown as an EXC, the place where it is thrown + some flags indicating whether to add more info, while if it is thrown as an ERR, the context where it is thrown. Derived classes can add their own data. These exceptions can be concatenated through the chainTo() method. Use cases:

  • To throw an exception:
    throw(YourExcClass{"expl",data}.asEXC("place",flags));
  • To throw an error:
    throw(YourExcClass{"expl",data}.asERR("context"));
  • To rethrow an exception or an error: just throw(it). Its type is preserved.
  • To define a new exception:
    class YourException: public Exc // or other class derived from Exc
    {
    public:
    YourException(const std::string & explanation): Exc{explanation} {}
    ELE_CLASS_OVERRIDE(YourException)
    }
    Base class for all errors / exceptions in Elementa. Just derive from it.
    Definition: exceptions.h:113

If an exception is thrown without calling the .asERR() method or the .asEXC() method, it is called in EXC mode with place empty. You can catch a derived exception (by their class name) or the base one, or even the std::runtime_error from which all of them derive, if you wish.

Definition at line 112 of file exceptions.h.

Inheritance diagram for elementa::base::Exc:
Collaboration diagram for elementa::base::Exc:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

Constructors
 Exc (const std::string &expl)
 Constructor from an explanation. To be thrown as EXC by default. More...
 
 Exc (const Exc &)=default
 
 Exc (Exc &&)=default
 
Excoperator= (const Exc &)=default
 
Excoperator= (Exc &&)=default
 
virtual ~Exc (void)=default
 
Launching methods
virtual ExcasERR (const std::string &context) noexcept
 Transform it to be thrown as ERR with the given context. More...
 
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ Exc()

elementa::base::Exc::Exc ( const std::string &  expl)
inline

Constructor from an explanation. To be thrown as EXC by default.

Definition at line 128 of file exceptions.h.

Member Function Documentation

◆ asERR()

virtual Exc & elementa::base::Exc::asERR ( const std::string &  context)
virtualnoexcept

◆ asEXC()

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexcept

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexcept

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexcept

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexcept

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::unimplemented

class elementa::base::unimplemented

Exception for indicating in runtime that a section of code is unimplemented.

This way of indicating unimplemented code should not be used in runtime except if it is the only way, i.e., when there is a section of code inside a function of method that otherwise it is implemented. Unimplemented functions or methods should be indicated by declaring them just without body (only their prototype). Unimplemented virtual methods, still, needs this runtime exception solution since, if left prototyped-only, base methods can still be called.

Definition at line 197 of file exceptions.h.

Inheritance diagram for elementa::base::unimplemented:
Collaboration diagram for elementa::base::unimplemented:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 unimplemented (const std::string &explanation)
 
unimplementedasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
unimplementedasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ unimplemented()

elementa::base::unimplemented::unimplemented ( const std::string &  explanation)
inline

Definition at line 201 of file exceptions.h.

Member Function Documentation

◆ asERR()

unimplemented & elementa::base::unimplemented::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 203 of file exceptions.h.

◆ asEXC() [1/2]

unimplemented & elementa::base::unimplemented::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 203 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::todo

class elementa::base::todo

Exception for indicating in runtime that a section of code is TODO.

This way of indicating TODO code should not be used in production, just while developing.

Definition at line 209 of file exceptions.h.

Inheritance diagram for elementa::base::todo:
Collaboration diagram for elementa::base::todo:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 todo (const std::string &explanation)
 
todoasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
todoasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ todo()

elementa::base::todo::todo ( const std::string &  explanation)
inline

Definition at line 213 of file exceptions.h.

Member Function Documentation

◆ asERR()

todo & elementa::base::todo::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 215 of file exceptions.h.

◆ asEXC() [1/2]

todo & elementa::base::todo::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 215 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::notreach

class elementa::base::notreach

Exception for indicating in runtime that a code should not be reached.

Definition at line 219 of file exceptions.h.

Inheritance diagram for elementa::base::notreach:
Collaboration diagram for elementa::base::notreach:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 notreach (const std::string &explanation)
 
notreachasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
notreachasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ notreach()

elementa::base::notreach::notreach ( const std::string &  explanation)
inline

Definition at line 223 of file exceptions.h.

Member Function Documentation

◆ asERR()

notreach & elementa::base::notreach::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 225 of file exceptions.h.

◆ asEXC() [1/2]

notreach & elementa::base::notreach::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 225 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::invstate

class elementa::base::invstate

Exception for indicating that some object is in invalid state.

Definition at line 229 of file exceptions.h.

Inheritance diagram for elementa::base::invstate:
Collaboration diagram for elementa::base::invstate:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 invstate (const std::string &expl)
 
invstateasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
invstateasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ invstate()

elementa::base::invstate::invstate ( const std::string &  expl)
inline

Definition at line 233 of file exceptions.h.

Member Function Documentation

◆ asERR()

invstate & elementa::base::invstate::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 235 of file exceptions.h.

◆ asEXC() [1/2]

invstate & elementa::base::invstate::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 235 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::internal_error

class elementa::base::internal_error

Exception for indicating some internal error not caused by user of object.

Definition at line 239 of file exceptions.h.

Inheritance diagram for elementa::base::internal_error:
Collaboration diagram for elementa::base::internal_error:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 internal_error (const std::string &expl)
 
internal_errorasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
internal_errorasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ internal_error()

elementa::base::internal_error::internal_error ( const std::string &  expl)
inline

Definition at line 243 of file exceptions.h.

Member Function Documentation

◆ asERR()

internal_error & elementa::base::internal_error::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 245 of file exceptions.h.

◆ asEXC() [1/2]

internal_error & elementa::base::internal_error::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 245 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::notfound

class elementa::base::notfound

Exception for indicating that some element has not been found in some place.

Definition at line 249 of file exceptions.h.

Inheritance diagram for elementa::base::notfound:
Collaboration diagram for elementa::base::notfound:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 notfound (const std::string &expl)
 
notfoundasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
notfoundasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ notfound()

elementa::base::notfound::notfound ( const std::string &  expl)
inline

Definition at line 253 of file exceptions.h.

Member Function Documentation

◆ asERR()

notfound & elementa::base::notfound::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 255 of file exceptions.h.

◆ asEXC() [1/2]

notfound & elementa::base::notfound::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 255 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::invarg

class elementa::base::invarg

Exception for indicating that some argument of a method/function is invalid.

Definition at line 259 of file exceptions.h.

Inheritance diagram for elementa::base::invarg:
Collaboration diagram for elementa::base::invarg:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 invarg (const std::string &expl)
 
invargasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
invargasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ invarg()

elementa::base::invarg::invarg ( const std::string &  expl)
inline

Definition at line 263 of file exceptions.h.

Member Function Documentation

◆ asERR()

invarg & elementa::base::invarg::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 265 of file exceptions.h.

◆ asEXC() [1/2]

invarg & elementa::base::invarg::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 265 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

◆ elementa::base::outofrange

class elementa::base::outofrange

Exception for indicating that some value is out of range.

Definition at line 269 of file exceptions.h.

Inheritance diagram for elementa::base::outofrange:
Collaboration diagram for elementa::base::outofrange:

Public Types

Types, consts., etc.
using StdBase = std::runtime_error
 

Public Member Functions

 outofrange (const std::string &expl)
 
outofrangeasERR (const std::string &contxt) noexcept override
 Transform it to be thrown as ERR with the given context. More...
 
outofrangeasEXC (const std::string &place, const elementa::base::RTTextWithEnum::Combination &fl={elementa::base::RTTextWith::kAll_}) noexcept override
 
Launching methods
virtual ExcasEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
 Transform it to be thrown as EXC with the given place and flags. More...
 
Catching methods
const char * what (void) const noexcept override
 Return the complete message. It will live as long as this exception. More...
 
const char * explanation (void) const noexcept
 Return the explanation only. It will live as long as this exception. More...
 
const char * context (void) const noexcept
 Return the place (EXC) or context (ERR) only. Will live as long as this. More...
 

Member Typedef Documentation

◆ StdBase

using elementa::base::Exc::StdBase = std::runtime_error
inherited

Definition at line 119 of file exceptions.h.

Constructor & Destructor Documentation

◆ outofrange()

elementa::base::outofrange::outofrange ( const std::string &  expl)
inline

Definition at line 273 of file exceptions.h.

Member Function Documentation

◆ asERR()

outofrange & elementa::base::outofrange::asERR ( const std::string &  context)
inlineoverridevirtualnoexcept

Transform it to be thrown as ERR with the given context.

Reimplemented from elementa::base::Exc.

Definition at line 275 of file exceptions.h.

◆ asEXC() [1/2]

outofrange & elementa::base::outofrange::asEXC ( const std::string &  place,
const elementa::base::RTTextWithEnum::Combination &  fl = {elementa::base::RTTextWith::kAll_} 
)
inlineoverridenoexcept

Definition at line 275 of file exceptions.h.

◆ asEXC() [2/2]

virtual Exc & elementa::base::Exc::asEXC ( const std::string &  place,
const RTTextWithEnum::Combination &  flags = {RTTextWith::kAll_} 
)
virtualnoexceptinherited

Transform it to be thrown as EXC with the given place and flags.

The flags are explained in debugging.h, runtime_src_place() function.

Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().

◆ what()

const char * elementa::base::Exc::what ( void  ) const
inlineoverridenoexceptinherited

Return the complete message. It will live as long as this exception.

The message will be one-line except if the explanation or place/context contain some CR.

Definition at line 161 of file exceptions.h.

◆ explanation()

const char * elementa::base::Exc::explanation ( void  ) const
inlinenoexceptinherited

Return the explanation only. It will live as long as this exception.

Definition at line 164 of file exceptions.h.

◆ context()

const char * elementa::base::Exc::context ( void  ) const
inlinenoexceptinherited

Return the place (EXC) or context (ERR) only. Will live as long as this.

Definition at line 167 of file exceptions.h.

Macro Definition Documentation

◆ ELE_CLASS_EXCOVERRIDE

#define ELE_CLASS_EXCOVERRIDE (   C)

#include <elementa/base/exceptions.h>

Value:
C & asERR(const std::string & contxt) noexcept\
override \
return(*this); } \
C & asEXC(const std::string & place, \
const elementa::base::RTTextWithEnum::\
Combination & fl =\
{elementa::base::RTTextWith::kAll_}) \
noexcept override\
return(*this); }
virtual Exc & asEXC(const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept
Transform it to be thrown as EXC with the given place and flags.
virtual Exc & asERR(const std::string &context) noexcept
Transform it to be thrown as ERR with the given context.

Shortening macro that must be used inside classes derived from Exc.

The overriden methods it defines serve to catch those derived classes properly; otherwise the base methods asERR() and asEXC() will be used that return Exc objects, losing the derived class identity.

Definition at line 64 of file exceptions.h.

◆ ELE_CODE_UNIMPLEMENTED

#define ELE_CODE_UNIMPLEMENTED

#include <elementa/base/exceptions.h>

Value:
"Unimplemented"}.asEXC(ELE_CODE_PLACE))
#define ELE_CODE_PLACE
Produces a std::string with the place of source where the macro is placed.
Definition: debugging.h:194
Exception for indicating in runtime that a section of code is unimplemented.
Definition: exceptions.h:198

To throw an unimplemented exception.

Definition at line 289 of file exceptions.h.

◆ ELE_CODE_TODO

#define ELE_CODE_TODO (   expl)

#include <elementa/base/exceptions.h>

Value:
throw(elementa::base::todo{expl}.asEXC(\
Exception for indicating in runtime that a section of code is TODO.
Definition: exceptions.h:210

To throw a TODO exception.

Definition at line 293 of file exceptions.h.

◆ ELE_CODE_NOTREACH

#define ELE_CODE_NOTREACH

#include <elementa/base/exceptions.h>

Value:
"Should not reach this point"}.asEXC(\
Exception for indicating in runtime that a code should not be reached.
Definition: exceptions.h:220

To throw a should-not-reach-here exception.

Definition at line 297 of file exceptions.h.

◆ ELE_CODE_INTERNALERR

#define ELE_CODE_INTERNALERR (   expl)

#include <elementa/base/exceptions.h>

Value:
Exception for indicating some internal error not caused by user of object.
Definition: exceptions.h:240

To throw an internal-error exception with an explanation.

Definition at line 302 of file exceptions.h.

◆ ELE_CODE_INVSTATE

#define ELE_CODE_INVSTATE (   expl)

#include <elementa/base/exceptions.h>

Value:
Exception for indicating that some object is in invalid state.
Definition: exceptions.h:230

To throw an invalid-state exception with an explanation.

Definition at line 306 of file exceptions.h.

◆ ELE_CODE_INVARG

#define ELE_CODE_INVARG (   expl)

#include <elementa/base/exceptions.h>

Value:
throw(elementa::base::invarg{expl}.\
Exception for indicating that some argument of a method/function is invalid.
Definition: exceptions.h:260

To throw an invalid-argument exception with an explanation.

Definition at line 310 of file exceptions.h.

◆ ELE_CODE_OUTOFRANGE

#define ELE_CODE_OUTOFRANGE (   expl)

#include <elementa/base/exceptions.h>

Value:
Exception for indicating that some value is out of range.
Definition: exceptions.h:270

To throw an out-of-range exception with an explanation.

Definition at line 314 of file exceptions.h.

◆ ELE_CODE_NOTFOUND

#define ELE_CODE_NOTFOUND (   expl)

#include <elementa/base/exceptions.h>

Value:
Exception for indicating that some element has not been found in some place.
Definition: exceptions.h:250

To throw a not-found exception with an explanation.

Definition at line 318 of file exceptions.h.