diff --git a/app/controllers/alchemy/json_api/base_controller.rb b/app/controllers/alchemy/json_api/base_controller.rb index c89399a..13d0535 100644 --- a/app/controllers/alchemy/json_api/base_controller.rb +++ b/app/controllers/alchemy/json_api/base_controller.rb @@ -7,6 +7,23 @@ class BaseController < ::ApplicationController include JSONAPI::Errors include JSONAPI::Filtering include JSONAPI::Pagination + + private + + def render_jsonapi_internal_server_error(exception) + log_error(exception) + super + end + + def log_error(exception) + logger = Rails.logger + return unless logger + + message = +"\n#{exception.class} (#{exception.message}):\n" + message << exception.annotated_source_code.to_s if exception.respond_to?(:annotated_source_code) + message << " " << exception.backtrace.join("\n ") + logger.fatal("#{message}\n\n") + end end end end