Inheritance diagram for restcgi::exception:
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:
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_e & | status_code () const throw () |
const char * | what () const throw () |
const std::string & | errmsg () const |
virtual bool | inhibit_content () const |
const map_type & | map () const |
Get const map. | |
map_type & | map () |
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. |
typedef std::map<std::string, std::string> restcgi::exception::map_type |
map type
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.
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.