Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8a1fc36e
Commit
8a1fc36e
authored
Jul 29, 2019
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate argument errors as execution errors
parent
ab509c78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
app/controllers/graphql_controller.rb
app/controllers/graphql_controller.rb
+4
-0
spec/controllers/graphql_controller_spec.rb
spec/controllers/graphql_controller_spec.rb
+21
-0
No files found.
app/controllers/graphql_controller.rb
View file @
8a1fc36e
...
...
@@ -30,6 +30,10 @@ class GraphqlController < ApplicationController
render_error
(
exception
.
message
,
status: :unprocessable_entity
)
end
rescue_from
Gitlab
::
Graphql
::
Errors
::
ArgumentError
do
|
exception
|
render_error
(
exception
.
message
,
status: :unprocessable_entity
)
end
private
def
execute_multiplex
...
...
spec/controllers/graphql_controller_spec.rb
View file @
8a1fc36e
...
...
@@ -7,6 +7,27 @@ describe GraphqlController do
stub_feature_flags
(
graphql:
true
)
end
describe
'ArgumentError'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:message
)
{
'green ideas sleep furiously'
}
before
do
sign_in
(
user
)
end
it
'handles argument errors'
do
allow
(
subject
).
to
receive
(
:execute
)
do
raise
Gitlab
::
Graphql
::
Errors
::
ArgumentError
,
message
end
post
:execute
expect
(
json_response
).
to
include
(
'errors'
=>
include
(
a_hash_including
(
'message'
=>
message
))
)
end
end
describe
'POST #execute'
do
context
'when user is logged in'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
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