Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
Log message to sentry when json parse error occur
· 2cb439f9
Juan Manuel Solaro
authored
Dec 09, 2019
and
Brian Hatchet
committed
Dec 09, 2019
2cb439f9
Merge branch 'log-url-for-json-parse-error' into 'release/3.12.1'
· 13303989
Brian Hatchet
authored
Dec 09, 2019
Log message to sentry when json parse error occur See merge request
!447
13303989
Hide whitespace changes
Inline
Side-by-side
src/common/services/api.service.js
View file @
13303989
...
...
@@ -8,6 +8,8 @@ import abortableFetch from '../helpers/abortableFetch';
import
{
Version
}
from
'
../../config/Version
'
;
import
logService
from
'
./log.service
'
;
import
*
as
Sentry
from
'
@sentry/react-native
'
;
/**
* Api Error
*/
...
...
@@ -29,6 +31,16 @@ export const isApiForbidden = function(err) {
* Api service
*/
class
ApiService
{
async
parseJSON
(
response
)
{
try
{
return
await
response
.
json
();
}
catch
(
error
)
{
Sentry
.
captureMessage
(
`ISSUE #1572 URL:
${
response
.
url
}
, STATUS:
${
response
.
status
}
STATUSTEXT:
${
response
.
statusText
}
`
);
throw
error
;
}
}
/**
* Clear cookies
*/
...
...
@@ -113,7 +125,7 @@ class ApiService {
}
// Convert from JSON
const
data
=
await
response
.
json
(
);
const
data
=
await
this
.
parseJSON
(
response
);
// Failed on API side
if
(
data
.
status
!=
'
success
'
)
{
...
...
@@ -144,7 +156,7 @@ class ApiService {
}
// Convert from JSON
const
data
=
await
response
.
json
(
);
const
data
=
await
this
.
parseJSON
(
response
);
// Failed on API side
if
(
data
.
status
!=
'
success
'
)
{
...
...
@@ -175,7 +187,7 @@ class ApiService {
}
// Convert from JSON
const
data
=
await
response
.
json
(
);
const
data
=
await
this
.
parseJSON
(
response
);
// Failed on API side
if
(
data
.
status
===
'
error
'
)
{
...
...
@@ -251,7 +263,7 @@ class ApiService {
}
// Convert from JSON
const
data
=
await
response
.
json
(
);
const
data
=
await
this
.
parseJSON
(
response
);
// Failed on API side
if
(
data
.
status
===
'
error
'
)
{
...
...