Skip to content

Catchall error block fails to catch direct decendants of Exception #1548

@thesecretmaster

Description

@thesecretmaster

Because the conditional on this line checks for strictly less than instead of less than or equal to, error blocks are unable to catch any thing which is a direct descendant of Exception.

return false unless key.respond_to? :superclass and key.superclass < Exception

Here's a quick (untested) example:

require 'sinatra'

error do
  puts "Error block called!"
end

get "/" do
  raise StandardError
end

After visiting /, the error block will not be called. If this is by design, then this seems like a strange design decision. If it isn't, then I'd be happy to open a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions