Version 0.1
A very serious, industrial web framework in Tcl
 All Data Structures Namespaces Files Functions Variables Pages
Functions
tanzer::error Namespace Reference

Functions

 new status msg
 
 throw status msg
 
 run script
 
 servable error
 
 try script catch ename catchBlock
 
 fatal
 
 response error
 
 status e
 

Detailed Description

Provides structured error handling and reporting facilties as a namespace ensemble.

Structured exceptions are used to indicate to tanzer::server that an error is generated intentionally in response to an expected type of error condition, be it due to a malformed request or a malformed response from an external program.

Function Documentation

tanzer::error::fatal

Called as [tanzer::error fatal].

Generate a new 500 Internal Server Error.

tanzer::error::new   status msg  

Called as [tanzer::error new].

Create a new error object, representing an HTTP status code in $status and a human readable text representation in $msg.

tanzer::error::response   error  

Called as [tanzer::error response].

Generate a new tanzer::response object based on the tanzer::error object specified in $error. A full HTML response is generated, and the response body containing error text and a stylized page is buffered. The response object will be ready to be served by a tanzer::session session handler.

tanzer::error::run   script  

Called as [tanzer::error run].

Run the code specified in $script, and catch any errors. If the program encounters any structured exceptions thrown by the script body, then those are passed on with [error]. Otherwise, a new 500 Internal Server Error is generated with the message of the error thrown by $script.

Certain error conditions cause specific tanzer::error objects to be generated.

  • If $::errorCode indicates an ENOTDIR or an ENOENT, then a 404 File Not Found is thrown.
  • If $::errorCode indicates an EPERM, then a 403 Forbidden is thrown.
  • All other error conditions result in a 500 Internal Server Error.
tanzer::error::servable   error  

Called as [tanzer::error servable].

Returns a boolean indicating whether or not the error passed in $error can be served as an error page without a wrapper. In other words, this function returns true if $error is a tanzer::error object, and false if it is not.

tanzer::error::status   e  

Called as [tanzer::error status].

Return the error status code in the tanzer::error object specified in $e.

tanzer::error::throw   status msg  

Called as [tanzer::error throw].

Create and throw a new error object, representing an HTTP status code in $status and a human readable text representation in $msg.

tanzer::error::try   script catch ename catchBlock  

Called as [tanzer::error try].

Run $script through [catch]; if any errors are thrown, then they will be captured in a variable named in $ename and provided to the error handling code in $catchBlock.