Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Exceptions < Application
- skip_before :parse_supplied_sscj1
- skip_before :ensure_authenticated
- provides :sscj1
- # ...
- # handle RecordInvalid exceptions (406)
- def record_invalid
- @errors = request.exceptions.first.errors
- rename_error_fields!
- render
- end
- # handle client errors
- def client_error
- # Re-Raise so we get the pretty merb error document instead.
- raise request.exceptions.first if content_type == :html
- @exceptions = request.exceptions
- @show_details = Merb::Config[:exception_details]
- # Leave the :standard_error part, so that the other actions that call
- # this know what template to render
- render :client_error
- end
- # Everything else (500)
- def standard_error
- # Re-Raise so we get the pretty merb error document instead.
- raise request.exceptions.first if content_type == :html
- @exceptions = request.exceptions
- @show_details = Merb::Config[:exception_details]
- # Leave the :standard_error part, so that the other actions that call
- # this know what template to render
- render :standard_error
- end
- # We want some of the error fields to show up
- # under the service attribute names, rather than
- # the database column names, so here's what to
- # rename them to
- ERROR_FIELDS_TO_RENAME = {
- :template_path => :template_href
- }
- def rename_error_fields!
- ERROR_FIELDS_TO_RENAME.each do |from, to|
- v = @errors.delete(from)
- @errors[to] = v
- end
- end
- end
Add Comment
Please, Sign In to add comment