better error handling
This commit is contained in:
parent
1462404e23
commit
c0a3ceef00
2 changed files with 12 additions and 3 deletions
|
@ -563,11 +563,20 @@ const fetchTimeline = ({
|
|||
})
|
||||
return data
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((data) => {
|
||||
if (data.error || data.errors) {
|
||||
if (status >= 500) {
|
||||
return { errors: ['Server error'] }
|
||||
}
|
||||
return data.json()
|
||||
})
|
||||
.then((data) => {
|
||||
if (status >= 400) {
|
||||
console.log(data.error, data.errors)
|
||||
data.status = status
|
||||
data.statusText = statusText
|
||||
if (data.error) {
|
||||
data.errors = [data.error]
|
||||
}
|
||||
return data
|
||||
}
|
||||
return { data: data.map(isNotifications ? parseNotification : parseStatus), pagination }
|
||||
|
|
|
@ -49,7 +49,7 @@ const fetchAndUpdate = ({
|
|||
|
||||
return apiService.fetchTimeline(args)
|
||||
.then(response => {
|
||||
if (response.error || response.errors) {
|
||||
if (response.errors) {
|
||||
throw new Error(`${response.status} ${response.statusText}`)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue