15. Exception Handling
Exception Handling is the one of most important things to develpment web applications.
Nekonote Framework have the three ways to see some exception raised in your program.
Nekonote::Logger
There is the logger named Nekonote::Logger
on Nekonote Framework.
Nekonote::Logger
writes the exception details to a specific logfile when it turned on.
But when write_exception
directive in logger.yml
is set false
, the logger will not write any exception detail to the logfile.
GUI-based Debuger
Rack::ShowExceptions
is the middleware to display exception details on web blowser.
It’s turned on by default.
When you need to turn off Rack::ShowExceptions
you must edit middlewares.rb
.
preference/your_environment/middlewares.rb
# You may comment out something by putting #
# use Rack::ShowExceptions
While the route named `fatal` is defined in route_error.yml
, ShowExceptions
doesn't work, because `fatal` route takes precedence.
In that case, It will be good if you turn on the logger through logger.yml
to track exceptions.
ShowExceptions
is supposed to be disabled in productional environment for security reason.
Exception Objects
The exception object will be set to the property named @error
in the Handler class on fatal
route in route_error.yml
.
It’s possible to know the exception details by seeing @error
.