Module: Roda::RodaPlugins::ErrorHandler
- Defined in:
- lib/roda/plugins/error_handler.rb
Overview
The error_handler plugin adds an error handler to the routing, so that if routing the request raises an error, a nice error message page can be returned to the user.
You can provide the error handler as a block to the plugin:
plugin :error_handler do |e|
"Oh No!"
end
Or later via the error
class method:
plugin :error_handler
error do |e|
"Oh No!"
end
In both cases, the exception instance is passed into the block, and the block can return the request body via a string.
If an exception is raised, the response status will be set to 500 before executing the error handler. The error handler can change the response status if necessary.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.configure(app, &block) ⇒ Object
If a block is given, automatically call the
error
method on the Roda class with it.
Class Method Details
.configure(app, &block) ⇒ Object
If a block is given, automatically call the error
method on the Roda class with it.
30 31 32 33 34 |
# File 'lib/roda/plugins/error_handler.rb', line 30 def self.configure(app, &block) if block app.error(&block) end end |