I saw in examples that we can do exceptions catching by contoller
filters
like (rescue_from ActiveRecord::RecordNotFound, :with =>
:record_not_found)
but I don’t want to use this way, con my exceptions aren’t controller
wide,
they only related to some single action.
Also, it’s my first email to mailing group, if I composed it
incorrectly,
someone please let me know.
def some_action
raise Exception if some_falsy_value
rescue @message = ‘Error’
end
Don’t raise Exception. Raise some descendant of StandardError, like
RuntimeError (the default if you don’t specify a class) or (even
better) your own StandardError-derived exception class.
A straight-up exception will bypass all default “rescue” clauses and
in general indicates that something has gone badly wrong and the
program should end.
A straight-up exception will bypass all default “rescue” clauses and
in general indicates that something has gone badly wrong and the
program should end.