Show better error message if HTTP status code is 413
This commit is contained in:
parent
952a94495b
commit
14fbce0285
2 changed files with 13 additions and 2 deletions
|
@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Show better error message if HTTP status code is 413.
|
||||||
|
|
||||||
## [1.17.0] - 2023-03-15
|
## [1.17.0] - 2023-03-15
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -80,7 +80,14 @@ export async function handleResponse(
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let errorDescription
|
||||||
|
if (response.headers.get("Content-Type") === "application/json") {
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
throw new Error(data.error_description)
|
errorDescription = data.error_description
|
||||||
|
} else {
|
||||||
|
// Unexpected response
|
||||||
|
errorDescription = response.statusText
|
||||||
|
}
|
||||||
|
throw new Error(errorDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue