Please help me find the official documentation with a list of the types of of exceptions. I wrote this action:
def show
begin
@user = User.find(params[:id])
rescue ActiveRecord::RecordNotFound => e
logger.debug e
logger.debug "Error #{$!}"
render_404
end
end
I need to mention several types of exceptions:
def show
begin
@user = User.find(params[:id])
rescue ActiveRecord::RecordNotFound => e
logger.debug e
logger.debug "Error #{$!}"
render_404
rescue anotherExceptionType1 => e
......
......
.....
rescue anotherExceptionType2 => e
......
......
.....
rescue anotherExceptionType3 => e
......
......
.....
end
end
but I did not find the list of exceptions in the documentation.
You can see all the subclasses of ActiveRecordError here: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/errors.rb
I can give you a list of exceptions but I am not sure if that is what you really want. Instead you probably want to figure out which exceptions will be thrown in your specific case. More importantly you probably should not be rescuing exceptions to begin with. For more information take a look at this link
However you asked for a list so here you go:
You can visit the link to find a hierarchy of the errors as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With