Skip to content

Sinatra's error handler with custom exceptions does not work #403

@renchap

Description

@renchap

Sinatra's doc used : http://sinatra-book.gittr.com/#error_handling

In some models, i raise a Picture::NotFound exception :
class Picture
...
class NotFound < Exception
end

  def initialize
    ...
    raise Picture::NotFound, "Picture #{path} not found" unless File.file?(self.physical_path)
  end
end

And in app/app.rb :
class Picty < Padrino::Application
...
error Picture::NotFound do
render :haml, "%p Picture not found"
end
end

All I get in the logs is the usual not catched exeption message :
Picture::NotFound - Picture /A1/Ext/IMG_52fdsf46.jpg not found:
/home/renchap/dev/Picty/app/models/picture.rb:22:in `initialize'

Is it normal that this Sinatra behaviour does not work with Padrino ? I think this is very useful, and wish to be able to use it.

I tried to move the error ... declaration to the controller, but it does not work either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions