Module: Tzispa::Api::HandlerError
- Included in:
- Handler
- Defined in:
- lib/tzispa/api/handler_error.rb
Constant Summary collapse
- HANDLER_OK =
:ok
Instance Method Summary collapse
- #error? ⇒ Boolean
- #error_id ⇒ Object
- #error_message ⇒ Object
- #http_bad_gateway(code = nil) ⇒ Object
- #http_bad_request(code = nil) ⇒ Object
- #http_conflict(code = nil) ⇒ Object
- #http_forbidden(code = nil) ⇒ Object
- #http_gone(code = nil) ⇒ Object
- #http_not_aceptable(code = nil) ⇒ Object
- #http_not_found(code = nil) ⇒ Object
- #http_not_implemented(code = nil) ⇒ Object
- #http_server_error(code = nil) ⇒ Object
- #http_service_unavailable(code = nil) ⇒ Object
- #http_token_required(code = nil) ⇒ Object
- #http_unauthorized(code = nil) ⇒ Object
Instance Method Details
#error? ⇒ Boolean
14 15 16 |
# File 'lib/tzispa/api/handler_error.rb', line 14 def error? @error && @error != HANDLER_OK end |
#error_id ⇒ Object
22 23 24 |
# File 'lib/tzispa/api/handler_error.rb', line 22 def error_id "#{self.class.name.dottize}.#{error}" if error end |
#error_message ⇒ Object
18 19 20 |
# File 'lib/tzispa/api/handler_error.rb', line 18 def I18n.t(error_id, default: error.to_s) if error end |
#http_bad_gateway(code = nil) ⇒ Object
66 67 68 |
# File 'lib/tzispa/api/handler_error.rb', line 66 def http_bad_gateway(code = nil) error_status code || :bad_gateway, 502 end |
#http_bad_request(code = nil) ⇒ Object
26 27 28 |
# File 'lib/tzispa/api/handler_error.rb', line 26 def http_bad_request(code = nil) error_status code || :bad_request, 400 end |
#http_conflict(code = nil) ⇒ Object
46 47 48 |
# File 'lib/tzispa/api/handler_error.rb', line 46 def http_conflict(code = nil) error_status code || :conflict, 409 end |
#http_forbidden(code = nil) ⇒ Object
34 35 36 |
# File 'lib/tzispa/api/handler_error.rb', line 34 def http_forbidden(code = nil) error_status code || :forbidden, 403 end |
#http_gone(code = nil) ⇒ Object
50 51 52 |
# File 'lib/tzispa/api/handler_error.rb', line 50 def http_gone(code = nil) error_status code || :gone, 410 end |
#http_not_aceptable(code = nil) ⇒ Object
42 43 44 |
# File 'lib/tzispa/api/handler_error.rb', line 42 def http_not_aceptable(code = nil) error_status code || :not_acceptable, 406 end |
#http_not_found(code = nil) ⇒ Object
38 39 40 |
# File 'lib/tzispa/api/handler_error.rb', line 38 def http_not_found(code = nil) error_status code || :not_found, 404 end |
#http_not_implemented(code = nil) ⇒ Object
62 63 64 |
# File 'lib/tzispa/api/handler_error.rb', line 62 def http_not_implemented(code = nil) error_status code || :not_implemented, 501 end |
#http_server_error(code = nil) ⇒ Object
58 59 60 |
# File 'lib/tzispa/api/handler_error.rb', line 58 def http_server_error(code = nil) error_status code || :internal_server_error, 500 end |
#http_service_unavailable(code = nil) ⇒ Object
70 71 72 |
# File 'lib/tzispa/api/handler_error.rb', line 70 def http_service_unavailable(code = nil) error_status code || :service_unavailable, 503 end |
#http_token_required(code = nil) ⇒ Object
54 55 56 |
# File 'lib/tzispa/api/handler_error.rb', line 54 def http_token_required(code = nil) error_status code || :token_required, 499 end |
#http_unauthorized(code = nil) ⇒ Object
30 31 32 |
# File 'lib/tzispa/api/handler_error.rb', line 30 def (code = nil) error_status code || :unauthorized, 401 end |