restcgi::exception Class Reference

Inheritance diagram for restcgi::exception:

restcgi::bad_request restcgi::conflict restcgi::gone restcgi::internal_server_error restcgi::method_not_allowed restcgi::no_content restcgi::not_found restcgi::not_modified restcgi::precondition_failed restcgi::request_entity_too_large restcgi::reset_content restcgi::see_other restcgi::unauthorized restcgi::unsupported_media_type List of all members.

Detailed Description

Base class for throwing exceptions when processing HTTP methods.

This has information about the HTTP status code so that exception responses can be automatically generated, see ctmpl. Note that not all exceptions are considered "errors", per se (e.g. not modified).

This contains a map of name-value string pairs. Member data of derived classes are inserted into the map with the name the same as the accessor method with "exception_" prefixed, e.g. not_found has a uri_path_rem() accessor method which will store the value under "exception_uri_path_rem". Application code can also store arbitrary variables for passing to the content template.

Special variables are inserted into the map by the base exception class:

See also:
status_code_e, ctmpl


Public Types

typedef std::map< std::string,
std::string > 
map_type

Public Member Functions

 exception (const status_code_e &sc, const std::string &errmsg="") throw ()
const status_code_estatus_code () const throw ()
const char * what () const throw ()
const std::string & errmsg () const
virtual bool inhibit_content () const
const map_typemap () const
 Get const map.
map_typemap ()
bool insert (const std::string &name, const std::string &value)
virtual void copy_hdr_flds (map_type &map) const
 Copy hdr field name and values.

Static Public Attributes

static const char * VARIABLE_NAME_PREFIX
 variable name prefix ("exception_")

Protected Member Functions

bool exception_insert (const std::string &name, const std::string &value)
 Prefix name and insert with value.


Member Typedef Documentation

typedef std::map<std::string, std::string> restcgi::exception::map_type

map type


Constructor & Destructor Documentation

restcgi::exception::exception ( const status_code_e sc,
const std::string &  errmsg = "" 
) throw ()

Construct. Note the dervided classes, e.g. not_found, set the arguments automatically.


Member Function Documentation

const std::string& restcgi::exception::errmsg (  )  const [inline]

Get errmsg.

virtual bool restcgi::exception::inhibit_content (  )  const [inline, virtual]

Inhibit content? Some status codes prohibit the sending of entity content, this indicates exception is for such a status code (e.g. NOT_MODIFIED).

Reimplemented in restcgi::no_content, restcgi::reset_content, and restcgi::not_modified.

bool restcgi::exception::insert ( const std::string &  name,
const std::string &  value 
)

Insert name and value into map if name not in map, returning whether inserted. Application code can use this, before throwing the exception, for passing variable values to the content template (ctmpl).

map_type& restcgi::exception::map (  )  [inline]

Get map.

const status_code_e& restcgi::exception::status_code (  )  const throw () [inline]

Get status code.

const char* restcgi::exception::what (  )  const throw () [inline]

Get what string. This is the status code, e.g. "304 Not Modified", plus an error message (preceded by a ": "), if any.


Generated on Fri May 15 11:27:12 2009 for restcgi by  doxygen 1.4.7