CBMC
Loading...
Searching...
No Matches
cprover_exception_baset Class Reference

Base class for exceptions thrown in the cprover project. More...

#include <c_errors.h>

Inheritance diagram for cprover_exception_baset:
Collaboration diagram for cprover_exception_baset:

Public Member Functions

virtual std::string what () const
 A human readable description of what went wrong.
virtual ~cprover_exception_baset ()=default
virtual std::string what () const
 A human readable description of what went wrong.
virtual ~cprover_exception_baset ()=default
 cprover_exception_baset ()=default
 cprover_exception_baset (cprover_exception_baset &&)=default
 cprover_exception_baset (const cprover_exception_baset &src)
std::string reason () const

Protected Member Functions

 cprover_exception_baset (std::string reason)
 This constructor is marked protected to ensure this class isn't used directly.
 cprover_exception_baset (std::string reason)
 This constructor is marked protected to ensure this class isn't used directly.

Protected Attributes

std::string reason
 The reason this exception was generated.
std::ostringstream _reason
 The reason this exception was generated.

Friends

template<typename E, typename T>
std::enable_if_t< std::is_base_of< cprover_exception_baset, std::decay_t< E > >::value, E && > operator<< (E &&e, const T &message)
 add to the diagnostic information in the given cprover_exception_baset exception; the type of the exception is preserved, enabling throw some_exceptiont{...} << "text"

Detailed Description

Base class for exceptions thrown in the cprover project.

Intended to be used as a convenient way to have a "catch all and report errors" from application entry points. Note that the reason we use a custom base class as opposed to std::exception or one of its derivates to avoid them being accidentally caught by code expecting standard exceptions to be only thrown by the standard library.

Definition at line 63 of file c_errors.h.

Constructor & Destructor Documentation

◆ ~cprover_exception_baset() [1/2]

virtual cprover_exception_baset::~cprover_exception_baset ( )
virtualdefault

◆ cprover_exception_baset() [1/5]

cprover_exception_baset::cprover_exception_baset ( std::string reason)
inlineexplicitprotected

This constructor is marked protected to ensure this class isn't used directly.

Deriving classes should be used to more precisely describe the problem that occurred.

Definition at line 76 of file c_errors.h.

◆ ~cprover_exception_baset() [2/2]

virtual cprover_exception_baset::~cprover_exception_baset ( )
virtualdefault

◆ cprover_exception_baset() [2/5]

cprover_exception_baset::cprover_exception_baset ( )
default

◆ cprover_exception_baset() [3/5]

cprover_exception_baset::cprover_exception_baset ( cprover_exception_baset && )
default

◆ cprover_exception_baset() [4/5]

cprover_exception_baset::cprover_exception_baset ( const cprover_exception_baset & src)
inline

Definition at line 41 of file exception_utils.h.

◆ cprover_exception_baset() [5/5]

cprover_exception_baset::cprover_exception_baset ( std::string reason)
inlineexplicitprotected

This constructor is marked protected to ensure this class isn't used directly.

Deriving classes should be used to more precisely describe the problem that occurred.

Definition at line 55 of file exception_utils.h.

Member Function Documentation

◆ reason()

std::string cprover_exception_baset::reason ( ) const
inline

Definition at line 46 of file exception_utils.h.

◆ what() [1/2]

std::string cprover_exception_baset::what ( ) const
virtual

A human readable description of what went wrong.

For readability, implementors should not add a leading or trailing newline to this description.

Reimplemented in incorrect_goto_program_exceptiont, invalid_command_line_argument_exceptiont, invalid_function_contract_pair_exceptiont, invalid_restriction_exceptiont, and invalid_source_file_exceptiont.

Definition at line 12 of file exception_utils.cpp.

◆ what() [2/2]

virtual std::string cprover_exception_baset::what ( ) const
virtual

A human readable description of what went wrong.

For readability, implementors should not add a leading or trailing newline to this description.

Reimplemented in incorrect_goto_program_exceptiont, invalid_command_line_argument_exceptiont, invalid_function_contract_pair_exceptiont, invalid_restriction_exceptiont, and invalid_source_file_exceptiont.

◆ operator<<

template<typename E, typename T>
std::enable_if_t< std::is_base_of< cprover_exception_baset, std::decay_t< E > >::value, E && > operator<< ( E && e,
const T & message )
friend

add to the diagnostic information in the given cprover_exception_baset exception; the type of the exception is preserved, enabling throw some_exceptiont{...} << "text"

Definition at line 1 of file exception_utils.h.

Member Data Documentation

◆ _reason

std::ostringstream cprover_exception_baset::_reason
protected

The reason this exception was generated.

This is the string returned by what() unless that method is overridden. This is an ostringstream to enable efficient appending with <<.

Definition at line 64 of file exception_utils.h.

◆ reason

std::string cprover_exception_baset::reason
protected

The reason this exception was generated.

This is the string returned by what() unless that method is overridden

Definition at line 83 of file c_errors.h.


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