Module: JsonapiErrorsHandler
- Defined in:
- lib/jsonapi_errors_handler.rb,
lib/jsonapi_errors_handler/errors.rb,
lib/jsonapi_errors_handler/version.rb,
lib/jsonapi_errors_handler/error_mapper.rb,
lib/jsonapi_errors_handler/configuration.rb,
lib/jsonapi_errors_handler/errors/invalid.rb,
lib/jsonapi_errors_handler/error_serializer.rb,
lib/jsonapi_errors_handler/errors/forbidden.rb,
lib/jsonapi_errors_handler/errors/not_found.rb,
lib/jsonapi_errors_handler/keys_stringifier.rb,
lib/jsonapi_errors_handler/errors/unauthorized.rb,
lib/jsonapi_errors_handler/errors/standard_error.rb
Overview
Allows to handle ruby errors and return the serialized JSON:API output
Defined Under Namespace
Modules: Errors
Classes: Configuration, ErrorMapper, ErrorSerializer, KeysStringifier
Constant Summary
collapse
- PREDEFINED_HASH =
{
'JsonapiErrorsHandler::Errors::Invalid' =>
'JsonapiErrorsHandler::Errors::Invalid',
'JsonapiErrorsHandler::Errors::Forbidden' =>
'JsonapiErrorsHandler::Errors::Forbidden',
'JsonapiErrorsHandler::Errors::NotFound' => '
JsonapiErrorsHandler::Errors::NotFound',
'JsonapiErrorsHandler::Errors::Unauthorized' =>
'JsonapiErrorsHandler::Errors::Unauthorized'
}.freeze
- VERSION =
'0.6.0'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
59
60
61
|
# File 'lib/jsonapi_errors_handler.rb', line 59
def self.configure(&block)
Configuration.instance.configure(&block)
end
|
Instance Method Details
#handle_error(error) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/jsonapi_errors_handler.rb', line 29
def handle_error(error)
log_error(error) if respond_to?(:log_error)
if JsonapiErrorsHandler::ErrorMapper.mapped_error?(error.class.superclass.to_s)
return render_error(error)
end
mapped = ErrorMapper.mapped_error(error)
mapped ? render_error(mapped) : handle_unexpected_error(error)
end
|
#handle_unexpected_error(error) ⇒ Object
#render_error(error) ⇒ Object