webmcp
view framework/env/request/add_error_handler.lua @ 518:02d505b6090c
Added section about global variables and the environment to WebMCP's documentation
| author | jbe | 
|---|---|
| date | Mon Aug 21 14:50:27 2017 +0200 (2017-08-21) | 
| parents | d89813dd4d92 | 
| children | 
 line source
     1 --[[--
     2 request.add_error_handler(
     3   function(errobj, stacktrace)
     4     ...
     5   end
     6 )
     8 Registers a function to be called after an error occurred during request handling and the error response has been prepared by filling the "trace" and "system_error" slots in request.handler(...). The registered handler may, for example, send an error report to an administrator (utilizing slot.render_layout(...)). The passed handler function gets the error message (or error object) passed as first argument and the stacktrace as second argument.
    10 --]]--
    12 function request.add_error_handler(func)
    13   request.configure(function()
    14     local handlers = request._error_handlers
    15     handlers[#handlers+1] = func
    16   end)
    17 end
