Commit cd0aed3d authored by Marin Jankovski's avatar Marin Jankovski

Add a message when unable to save an object through api.

parent 0da5154b
...@@ -108,7 +108,7 @@ module API ...@@ -108,7 +108,7 @@ module API
if note.save if note.save
present note, with: Entities::CommitNote present note, with: Entities::CommitNote
else else
render_api_error!("Failed to save note #{note.errors.messages}", 422) render_api_error!("Failed to save note #{note.errors.messages}", 400)
end end
end end
end end
......
...@@ -58,7 +58,7 @@ module API ...@@ -58,7 +58,7 @@ module API
if key.valid? && user_project.deploy_keys << key if key.valid? && user_project.deploy_keys << key
present key, with: Entities::SSHKey present key, with: Entities::SSHKey
else else
render_validation_error!(key) render_api_error!("Failed to add key #{key.errors.messages}", 400)
end end
end end
......
...@@ -54,7 +54,7 @@ module API ...@@ -54,7 +54,7 @@ module API
if @group.save if @group.save
present @group, with: Entities::Group present @group, with: Entities::Group
else else
render_api_error!("Failed to save group #{@group.errors.messages}", 422) render_api_error!("Failed to save group #{@group.errors.messages}", 400)
end end
end end
...@@ -97,7 +97,7 @@ module API ...@@ -97,7 +97,7 @@ module API
if result if result
present group present group
else else
render_api_error!("Failed to transfer project #{project.errors.messages}", 422) render_api_error!("Failed to transfer project #{project.errors.messages}", 400)
end end
end end
end end
......
...@@ -104,7 +104,7 @@ module API ...@@ -104,7 +104,7 @@ module API
# Validate label names in advance # Validate label names in advance
if (errors = validate_label_params(params)).any? if (errors = validate_label_params(params)).any?
render_api_error!({ labels: errors }, 400) render_api_error!("Unable to validate label: #{errors}"}, 400)
end end
issue = ::Issues::CreateService.new(user_project, current_user, attrs).execute issue = ::Issues::CreateService.new(user_project, current_user, attrs).execute
...@@ -118,7 +118,7 @@ module API ...@@ -118,7 +118,7 @@ module API
present issue, with: Entities::Issue present issue, with: Entities::Issue
else else
render_validation_error!(issue) render_api_error!("Unable to create issue #{issue.errors.messages}", 400)
end end
end end
...@@ -142,7 +142,7 @@ module API ...@@ -142,7 +142,7 @@ module API
# Validate label names in advance # Validate label names in advance
if (errors = validate_label_params(params)).any? if (errors = validate_label_params(params)).any?
render_api_error!({ labels: errors }, 400) render_api_error!("Unable to validate label: #{errors}"}, 400)
end end
issue = ::Issues::UpdateService.new(user_project, current_user, attrs).execute(issue) issue = ::Issues::UpdateService.new(user_project, current_user, attrs).execute(issue)
...@@ -158,7 +158,7 @@ module API ...@@ -158,7 +158,7 @@ module API
present issue, with: Entities::Issue present issue, with: Entities::Issue
else else
render_validation_error!(issue) render_api_error!("Unable to update issue #{issue.errors.messages}", 400)
end end
end end
......
...@@ -37,7 +37,7 @@ module API ...@@ -37,7 +37,7 @@ module API
if label.valid? if label.valid?
present label, with: Entities::Label present label, with: Entities::Label
else else
render_validation_error!(label) render_api_error!("Unable to create label #{label.errors.messages}", 400)
end end
end end
...@@ -90,7 +90,7 @@ module API ...@@ -90,7 +90,7 @@ module API
if label.update(attrs) if label.update(attrs)
present label, with: Entities::Label present label, with: Entities::Label
else else
render_validation_error!(label) render_api_error!("Unable to create label #{label.errors.messages}", 400)
end end
end end
end end
......
...@@ -137,7 +137,7 @@ module API ...@@ -137,7 +137,7 @@ module API
# Validate label names in advance # Validate label names in advance
if (errors = validate_label_params(params)).any? if (errors = validate_label_params(params)).any?
render_api_error!({ labels: errors }, 400) render_api_error!("Unable to validate label: #{errors}"}, 400)
end end
merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, attrs).execute(merge_request) merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, attrs).execute(merge_request)
...@@ -233,7 +233,7 @@ module API ...@@ -233,7 +233,7 @@ module API
if note.save if note.save
present note, with: Entities::MRNote present note, with: Entities::MRNote
else else
render_validation_error!(note) render_api_error!("Failed to save note #{note.errors.messages}", 400)
end end
end end
end end
......
...@@ -48,7 +48,7 @@ module API ...@@ -48,7 +48,7 @@ module API
if milestone.valid? if milestone.valid?
present milestone, with: Entities::Milestone present milestone, with: Entities::Milestone
else else
not_found!("Milestone #{milestone.errors.messages}") render_api_error!("Failed to create milestone #{milestone.errors.messages}", 400)
end end
end end
...@@ -72,7 +72,7 @@ module API ...@@ -72,7 +72,7 @@ module API
if milestone.valid? if milestone.valid?
present milestone, with: Entities::Milestone present milestone, with: Entities::Milestone
else else
not_found!("Milestone #{milestone.errors.messages}") render_api_error!("Failed to update milestone #{milestone.errors.messages}", 400)
end end
end end
end end
......
...@@ -93,7 +93,7 @@ module API ...@@ -93,7 +93,7 @@ module API
if @note.valid? if @note.valid?
present @note, with: Entities::Note present @note, with: Entities::Note
else else
bad_request!('Invalid note') render_api_error!("Failed to save note #{note.errors.messages}", 400)
end 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