The problem is that the default handler is defined in Sinatra :: ShowExceptions , which is controlled by the configuration parameter : raise_errors , and this parameter is all or nothing. If the : raise_errors parameter is disabled, the error method can be used in the Sinatra application, but it should be used for all exceptions, and there is no access to the error handler defined in Sinatra :: ShowExceptions . If it is enabled, all exceptions are handled by ShowExceptions middleware.
The rationale for what I want to do is that, at least during development, I want the "expected" errors to be handled in a friendly manner, and I want the "unexpected" errors to be handled in a friendly way to the developers.
I assume that the only way to do this is to define a rack middleware class that inherits from Sinatra :: ShowExceptions , and which has an additional option in its use to indicate which exception classes to handle or not to process.
Is there an easier way that I am missing?
(I use jruby if that matters.)
source
share