Module: ActAsJsonapi::JSONErrors
- Extended by:
- ActiveSupport::Concern
- Included in:
- Controller
- Defined in:
- lib/act_as_jsonapi/json_errors.rb
Instance Method Summary collapse
- #render_bad_request ⇒ Object
- #render_conflict_request ⇒ Object
- #render_error(error_status, detail_code = nil, detail_meta = nil) ⇒ Object
- #render_failed_dependency ⇒ Object
- #render_forbidden(ex) ⇒ Object
- #render_not_authorized ⇒ Object
- #render_not_found ⇒ Object
- #render_service_unavailable ⇒ Object
- #render_unprocessable_entity ⇒ Object
- #serializable(error_status, detail, detail_meta) ⇒ Object
- #translate_detail_code(detail_code) ⇒ Object
Instance Method Details
#render_bad_request ⇒ Object
28 29 30 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 28 def render_bad_request render_error :bad_request end |
#render_conflict_request ⇒ Object
52 53 54 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 52 def render_conflict_request render_error :conflict end |
#render_error(error_status, detail_code = nil, detail_meta = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 18 def render_error(error_status, detail_code = nil, = nil ) detail = translate_detail_code(detail_code) serializer = ::RequestErrorSerializer.new serializable(error_status, detail , ) render_json_api serializer, status: error_status end |
#render_failed_dependency ⇒ Object
40 41 42 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 40 def render_failed_dependency render_error :failed_dependency end |
#render_forbidden(ex) ⇒ Object
36 37 38 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 36 def render_forbidden(ex) render_error :forbidden, :err_forbidden, ex. end |
#render_not_authorized ⇒ Object
32 33 34 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 32 def render_error :unauthorized end |
#render_not_found ⇒ Object
24 25 26 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 24 def render_not_found render_error :not_found end |
#render_service_unavailable ⇒ Object
48 49 50 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 48 def render_service_unavailable render_error :service_unavailable end |
#render_unprocessable_entity ⇒ Object
44 45 46 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 44 def render_unprocessable_entity render_error :unprocessable_entity end |
#serializable(error_status, detail, detail_meta) ⇒ Object
8 9 10 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 8 def serializable(error_status, detail, ) StatusCodeResponse.serializable(error_status, detail, ) end |
#translate_detail_code(detail_code) ⇒ Object
12 13 14 15 16 |
# File 'lib/act_as_jsonapi/json_errors.rb', line 12 def translate_detail_code(detail_code) detail = I18n.t("error_messages.#{detail_code.to_s}") return detail unless detail.include?("translation missing") detail = I18n.t("error_messages.err_standard") end |