Skip to content

Commit

Permalink
Merge pull request #16 from AlchemyCMS/better-errors
Browse files Browse the repository at this point in the history
Log errors into standard out
  • Loading branch information
tvdeyen authored Nov 13, 2020
2 parents c6e5875 + 7ad18e7 commit 8f738c2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/controllers/alchemy/json_api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8f738c2

Please sign in to comment.