diff --git a/lib/potassium/recipes/api.rb b/lib/potassium/recipes/api.rb index 6c56269e..3504b2cb 100644 --- a/lib/potassium/recipes/api.rb +++ b/lib/potassium/recipes/api.rb @@ -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