Commit b2b2b2f9 authored by James Lopez's avatar James Lopez Committed by Robert Speicher
Browse files

fix create service error handling - missing setting import status to failed

parent 74849f97
......@@ -56,14 +56,14 @@ def execute
after_create_actions if @project.persisted?
@project.add_import_job if @project.import?
if @project.errors.empty?
@project.add_import_job if @project.import?
else
fail(error: @project.errors.join(', '))
end
@project
rescue => e
message = "Unable to save project: #{e.message}"
Rails.logger.error(message)
@project.errors.add(:base, message) if @project
@project
fail(error: e.message)
end
protected
......@@ -103,5 +103,19 @@ def save_project_and_import_data(import_data)
end
end
end
def fail(error:)
message = "Unable to save project. Error: #{error}"
message << "Project ID: #{@project.id}" if @project && @project.id
Rails.logger.error(message)
if @project && @project.import?
@project.errors.add(:base, message)
@project.mark_import_as_failed(message)
end
@project
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment