-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overwrite middleware to handle errors.
- Loading branch information
Marc Grimme
committed
Jun 25, 2016
1 parent
8e7d5df
commit 2738115
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module LogStasher | ||
module ActionDispatch | ||
class DebugExceptions < ::ActionDispatch::DebugExceptions | ||
private | ||
def log_error(env, wrapper) | ||
logger = logger(env) | ||
return unless logger | ||
|
||
::ActiveSupport::Deprecation.silence do | ||
logger << LogStasher.build_logstash_event(build_exception_hash(wrapper), ["exception"]).to_json + "\n" | ||
end | ||
end | ||
|
||
def build_exception_hash(wrapper) | ||
exception = wrapper.exception | ||
trace = wrapper.application_trace | ||
trace = wrapper.framework_trace if trace.empty? | ||
|
||
{ error: | ||
({ exception: exception.class, message: exception.message, trace: trace}. | ||
merge!( exception.respond_to?(:annotated_source_code) && { annotated_source_code: exception.annoted_source_code } || {} )) | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters