Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gpt
large_projects
gitlabhq1
Commits
44c62f1e
Commit
44c62f1e
authored
12 years ago
by
Drew Blessing
Browse files
Options
Download
Email Patches
Plain Diff
First crack at fixing the 409 problems
parent
da98cebc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
lib/api/helpers.rb
lib/api/helpers.rb
+10
-0
lib/api/projects.rb
lib/api/projects.rb
+2
-0
No files found.
lib/api/helpers.rb
View file @
44c62f1e
...
...
@@ -60,6 +60,11 @@ module API
attrs
end
def
handle_activerecord_errors
(
errors
)
attribute
,
message
=
errors
.
first
conflict!
(
attribute
)
if
message
==
'has already been taken'
end
# error helpers
def
forbidden!
...
...
@@ -87,6 +92,11 @@ module API
render_api_error!
(
'Method Not Allowed'
,
405
)
end
def
conflict!
(
attribute
)
message
=
"409 "
+
attribute
.
to_s
.
camelize
+
" has already been taken"
render_api_error!
(
message
,
409
)
end
def
render_api_error!
(
message
,
status
)
error!
({
'message'
=>
message
},
status
)
end
...
...
This diff is collapsed.
Click to expand it.
lib/api/projects.rb
View file @
44c62f1e
...
...
@@ -85,6 +85,7 @@ module API
if
@project
.
errors
[
:limit_reached
].
present?
error!
(
@project
.
errors
[
:limit_reached
],
403
)
end
handle_activerecord_errors
(
@project
.
errors
)
not_found!
end
end
...
...
@@ -116,6 +117,7 @@ module API
if
@project
.
saved?
present
@project
,
with:
Entities
::
Project
else
handle_activerecord_errors
(
@project
.
errors
)
not_found!
end
end
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment