Module: Miscellany::HttpErrorHandling
- Extended by:
- ActiveSupport::Concern
- Included in:
- SlicedResponse
- Defined in:
- lib/miscellany/controller/http_error_handling.rb
Defined Under Namespace
Modules: ClassMethods Classes: HttpError, UnauthorizedError
Instance Method Summary collapse
Instance Method Details
#render_http_error(err, status: nil, message: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/miscellany/controller/http_error_handling.rb', line 51 def render_http_error(err, status: nil, message: nil) status = err.status if err.is_a?(HttpError) && status.nil? status ||= 400 ||= err. ..call(err) if .is_a?(Proc) response_json = { status: status } response_json[:message] = if .present? response_json.merge!(err.extra) render json: response_json, status: status end |