Catchall error block fails to catch direct decendants of Exception
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 12.5k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
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.
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the conditional in lib/sinatra/base.rb around line 1153, then reproduce the issue with the error block and GET / example from the report. Confirm that a direct descendant of Exception reaches the catchall handler and add regression coverage; done means the error block is called for that request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100