Show better error message if HTTP status code is 413

This commit is contained in:
silverpill 2023-03-19 17:58:30 +00:00
parent 952a94495b
commit 14fbce0285
2 changed files with 13 additions and 2 deletions

View file

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Changed
- Show better error message if HTTP status code is 413.
## [1.17.0] - 2023-03-15
### Added

View file

@ -80,7 +80,14 @@ export async function handleResponse(
return data
}
} else {
let errorDescription
if (response.headers.get("Content-Type") === "application/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)
}
}