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
48440e25
Commit
48440e25
authored
May 24, 2021
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better errors to users for CustomersDot API calls
Changelog: changed
parent
bfe2457a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
25 deletions
+8
-25
ee/lib/gitlab/subscription_portal/clients/rest.rb
ee/lib/gitlab/subscription_portal/clients/rest.rb
+4
-15
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
+1
-7
locale/gitlab.pot
locale/gitlab.pot
+3
-3
No files found.
ee/lib/gitlab/subscription_portal/clients/rest.rb
View file @
48440e25
...
...
@@ -36,18 +36,7 @@ module Gitlab
private
def
error_message
_
(
'We encountered an error and our team has been notified. Please try again.'
)
end
def
reparse_response
(
response
)
result
=
parse_response
(
response
)
if
!
result
[
:success
]
&&
result
[
:data
]
track_exception
(
result
[
:data
][
:errors
])
result
[
:data
][
:errors
]
=
error_message
end
result
_
(
'Our team has been notified. Please try again.'
)
end
def
track_exception
(
message
)
...
...
@@ -61,7 +50,7 @@ module Gitlab
def
http_get
(
path
,
headers
)
response
=
Gitlab
::
HTTP
.
get
(
"
#{
base_url
}
/
#{
path
}
"
,
headers:
headers
)
re
parse_response
(
response
)
parse_response
(
response
)
rescue
*
Gitlab
::
HTTP
::
HTTP_ERRORS
=>
e
track_exception
(
e
.
message
)
{
success:
false
,
data:
{
errors:
error_message
}
}
...
...
@@ -70,7 +59,7 @@ module Gitlab
def
http_post
(
path
,
headers
,
params
=
{})
response
=
Gitlab
::
HTTP
.
post
(
"
#{
base_url
}
/
#{
path
}
"
,
body:
params
.
to_json
,
headers:
headers
)
re
parse_response
(
response
)
parse_response
(
response
)
rescue
*
Gitlab
::
HTTP
::
HTTP_ERRORS
=>
e
track_exception
(
e
.
message
)
{
success:
false
,
data:
{
errors:
error_message
}
}
...
...
@@ -79,7 +68,7 @@ module Gitlab
def
http_put
(
path
,
headers
,
params
=
{})
response
=
Gitlab
::
HTTP
.
put
(
"
#{
base_url
}
/
#{
path
}
"
,
body:
params
.
to_json
,
headers:
headers
)
re
parse_response
(
response
)
parse_response
(
response
)
rescue
*
Gitlab
::
HTTP
::
HTTP_ERRORS
=>
e
track_exception
(
e
.
message
)
{
success:
false
,
data:
{
errors:
error_message
}
}
...
...
ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb
View file @
48440e25
...
...
@@ -6,7 +6,7 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::REST do
let
(
:client
)
{
Gitlab
::
SubscriptionPortal
::
Client
}
let
(
:http_response
)
{
nil
}
let
(
:http_method
)
{
:post
}
let
(
:error_message
)
{
'
We encountered an error and o
ur team has been notified. Please try again.'
}
let
(
:error_message
)
{
'
O
ur team has been notified. Please try again.'
}
let
(
:gitlab_http_response
)
do
double
(
code:
http_response
.
code
,
response:
http_response
,
body:
{},
parsed_response:
{})
end
...
...
@@ -24,9 +24,7 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::REST do
shared_examples
'when http call raises an exception'
do
it
'overrides the error message'
do
exception
=
Gitlab
::
HTTP
::
HTTP_ERRORS
.
first
.
new
tracked_exception
=
Gitlab
::
SubscriptionPortal
::
Clients
::
REST
::
SubscriptionPortalRESTException
.
new
(
exception
.
message
)
allow
(
Gitlab
::
HTTP
).
to
receive
(
http_method
).
and_raise
(
exception
)
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
).
with
(
tracked_exception
)
result
=
subject
...
...
@@ -40,10 +38,8 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::REST do
it
'has a unprocessable entity status'
do
allow
(
Gitlab
::
HTTP
).
to
receive
(
http_method
).
and_return
(
gitlab_http_response
)
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
)
expect
(
subject
[
:success
]).
to
eq
(
false
)
expect
(
subject
[
:data
][
:errors
]).
to
eq
(
error_message
)
end
end
...
...
@@ -52,10 +48,8 @@ RSpec.describe Gitlab::SubscriptionPortal::Clients::REST do
it
'has a server error status'
do
allow
(
Gitlab
::
HTTP
).
to
receive
(
http_method
).
and_return
(
gitlab_http_response
)
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
)
expect
(
subject
[
:success
]).
to
eq
(
false
)
expect
(
subject
[
:data
][
:errors
]).
to
eq
(
error_message
)
end
end
...
...
locale/gitlab.pot
View file @
48440e25
...
...
@@ -23322,6 +23322,9 @@ msgstr ""
msgid "Otherwise, click the link below to complete the process:"
msgstr ""
msgid "Our team has been notified. Please try again."
msgstr ""
msgid "Out-of-compliance with this project's policies and should be removed"
msgstr ""
...
...
@@ -36365,9 +36368,6 @@ msgstr ""
msgid "We don't have enough data to show this stage."
msgstr ""
msgid "We encountered an error and our team has been notified. Please try again."
msgstr ""
msgid "We have found the following errors:"
msgstr ""
...
...
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