Exception/ Error Types

Summary
Throwable is the base exception class for Photon.
Constructor for a Throwable object, can specify as little or as much information as you’d like when throwing.
Similar to the std::exception family, all photon exceptions (the Throwable family) define what() that returns a description of the exception.
Get just the description portion of an exception, used for chaining exceptions.
Exception is the base exception class, all exceptions inherit from it, and it inherits from Throwable.
ArgumentException should be thrown when an argument is passed to a function that is invalid.
PreconditionException should be thrown when a precondition is not met.
RangeException should be thrown if something (such as an array bound) is out of bounds.
ResourceException should be thrown if there is a problem accessing a resource.
Error is the base error class, all errors inherit from it, and it inherits from Throwable.
MemoryError should be thrown if an error occurs while allocating memory.
APIError should be thrown if an error occurs in code which is not part of Photon.

Throwable

Throwable is the base exception class for Photon.

Throwable is pure virtual, and can not be used directly, Exception and Error are available for non-specific exceptions.  All exceptions have the same interface as Throwable.

Operators

ostream& << ThrowableAll exceptions defined here can be output via ‘<<’

Children

<Exception>Base class for all non-fatal exceptions.
<Error>Base class for all potentially fatal exceptions.
Summary
Constructor for a Throwable object, can specify as little or as much information as you’d like when throwing.
Similar to the std::exception family, all photon exceptions (the Throwable family) define what() that returns a description of the exception.
Get just the description portion of an exception, used for chaining exceptions.

Throwable

Throwable(const std::string &description =  std::string(),
const std::string &file =  std::string(),
uint line = 0) throw()

Constructor for a Throwable object, can specify as little or as much information as you’d like when throwing.

Parameters

descriptiondescription of why exception was thrown [default: empty]
filename of file where exception was thrown [default: empty]
lineline in file where exception was thrown [default: 0]

what

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

Similar to the std::exception family, all photon exceptions (the Throwable family) define what() that returns a description of the exception.

Returns: Formatted std::string describing the error

getDesc

std::string virtual getDesc() const throw()

Get just the description portion of an exception, used for chaining exceptions.

Returns: Unformatted std::string describing the cause of the error

Exception

Exception is the base exception class, all exceptions inherit from it, and it inherits from Throwable.  Exception should be used for hard to classify exceptions.

Exception and children should be used when a problem occurs which is recoverable.

See Also

Error

Parent

Throwable

Children

ArgumentException PreconditionException RangeException ResourceException

ArgumentException

ArgumentException should be thrown when an argument is passed to a function that is invalid.

Parent

Exception

PreconditionException

PreconditionException should be thrown when a precondition is not met.

Parent

Exception

RangeException

RangeException should be thrown if something (such as an array bound) is out of bounds.

Parent

Exception

ResourceException

ResourceException should be thrown if there is a problem accessing a resource.

Parent

Exception

Error

Error is the base error class, all errors inherit from it, and it inherits from Throwable.  Error should be used for hard to classify errors.

Errors should be used when a problem occurs which is difficult to just ignore, usually more severe than exceptions.

See Also

Exception

Parent

Throwable

Children

APIError MemoryError

MemoryError

MemoryError should be thrown if an error occurs while allocating memory.

Parent

Error

APIError

APIError should be thrown if an error occurs in code which is not part of Photon.

Parent

Throwable

Throwable(const std::string &description =  std::string(),
const std::string &file =  std::string(),
uint line = 0) throw()
Constructor for a Throwable object, can specify as little or as much information as you’d like when throwing.
std::string virtual what() const throw()
Similar to the std::exception family, all photon exceptions (the Throwable family) define what() that returns a description of the exception.
std::string virtual getDesc() const throw()
Get just the description portion of an exception, used for chaining exceptions.
Throwable is the base exception class for Photon.
Error is the base error class, all errors inherit from it, and it inherits from Throwable.
ArgumentException should be thrown when an argument is passed to a function that is invalid.
PreconditionException should be thrown when a precondition is not met.
RangeException should be thrown if something (such as an array bound) is out of bounds.
ResourceException should be thrown if there is a problem accessing a resource.
Exception is the base exception class, all exceptions inherit from it, and it inherits from Throwable.
APIError should be thrown if an error occurs in code which is not part of Photon.
MemoryError should be thrown if an error occurs while allocating memory.