Skip to content

Commit

Permalink
Merge pull request #226 from platanus/sentry-error-handler
Browse files Browse the repository at this point in the history
feat(api): add raven capture in error handler if sentry enabled
  • Loading branch information
rjherrera authored Sep 6, 2019
2 parents d601b47 + 584ca34 commit a033f41
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/potassium/recipes/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@ def add_api
HERE
end

api_error_concern_path = 'app/controllers/concerns/api_error_concern.rb'

copy_file '../assets/api/base_controller.rb', 'app/controllers/api/v1/base_controller.rb'
copy_file '../assets/api/api_error_concern.rb', 'app/controllers/concerns/api_error_concern.rb'
copy_file '../assets/api/api_error_concern.rb', api_error_concern_path
copy_file '../assets/api/responder.rb', 'app/responders/api_responder.rb'

if selected?(:report_error)
previous_line = 'logger.error exception.backtrace.join("\n")'
new_line = "\n Raven.capture_exception(exception)"
insert_into_file api_error_concern_path, new_line, after: previous_line
end
end
end
end

0 comments on commit a033f41

Please sign in to comment.