Honeycomb  0.1
Component-Model Framework
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
honey::Exception Class Reference

Base exception class. Exceptions inherited from this class provide debug info and can be thrown polymorphically (unlike standard c++ exceptions). More...

#include <Exception.h>

Inheritance diagram for honey::Exception:
Inheritance graph
[legend]
Collaboration diagram for honey::Exception:
Collaboration graph
[legend]

Classes

struct  MsgStream
 Custom error message builder. More...
 
struct  Raiser
 Helper to raise an exception after the right side of ^ has been evaluated. More...
 
struct  Source
 Info about source where exception was thrown. More...
 

Public Member Functions

 Exception ()=default
 
 Exception (const Exception &rhs)
 
Exceptionoperator= (const Exception &rhs)
 
const Sourcesource () const
 Get info about source where exception was thrown. More...
 
const Stringmessage () const
 Get custom error message. The error message can be appended to using global operator<<(Exception, String) More...
 
const char * what () const throw ()
 Get full diagnostic message. More...
 
template<class T >
MsgStream operator<< (T &&val)
 Append custom error message. More...
 
- Public Member Functions inherited from honey::SharedObj< Exception >
 SharedObj (Alloc &&a=Alloc()) debug_if(
 Construct with allocator that is called to deallocate this shared object when all references have been released. More...
 

Static Public Member Functions

static Ptr current ()
 Create a clone of the current exception caught with (...) More...
 

Protected Member Functions

virtual String createWhat () const
 Create what message. Called only on demand and result is cached. More...
 
- Protected Member Functions inherited from honey::SharedObj< Exception >
void finalize ()
 Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction. More...
 

Friends

ostream & operator<< (ostream &os, const Exception &e)
 

Detailed Description

Base exception class. Exceptions inherited from this class provide debug info and can be thrown polymorphically (unlike standard c++ exceptions).

All exceptions must inherit from this class and throw_ should be used instead of the throw keyword.
Default constructed exceptions are fast and lean (no overhead).

See also
throw_, EXCEPTION

Example:

struct MyExA : Exception    { EXCEPTION(MyExA) };
struct MyExB : MyExA        { EXCEPTION(MyExB) };

{
    throw_ MyExB() << "Optional Message";    //throw_ directly

    MyExA::Ptr a = new MyExB;
    throw_ *a << "Error";                    //throw_ polymorphically from base class, catch (MyExB& e)
}

Constructor & Destructor Documentation

honey::Exception::Exception ( )
default
honey::Exception::Exception ( const Exception rhs)
inline

Member Function Documentation

virtual String honey::Exception::createWhat ( ) const
inlineprotectedvirtual

Create what message. Called only on demand and result is cached.

Exception::Ptr honey::Exception::current ( )
inlinestatic

Create a clone of the current exception caught with (...)

const String& honey::Exception::message ( ) const
inline

Get custom error message. The error message can be appended to using global operator<<(Exception, String)

template<class T >
MsgStream honey::Exception::operator<< ( T &&  val)
inline

Append custom error message.

Exception& honey::Exception::operator= ( const Exception rhs)
inline
const Source& honey::Exception::source ( ) const
inline

Get info about source where exception was thrown.

const char* honey::Exception::what ( ) const
throw (
)
inline

Get full diagnostic message.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const Exception e 
)
friend

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