mirror of
https://github.com/gotson/komga.git
synced 2026-04-21 14:30:50 +02:00
add response body in error cause for komgaclient
This commit is contained in:
parent
9a811b0b66
commit
72e81d83a8
1 changed files with 5 additions and 3 deletions
|
|
@ -4,9 +4,11 @@ import type {paths} from '@/generated/openapi/komga'
|
|||
|
||||
// Middleware that throws on error, so it works with Pinia Colada
|
||||
const coladaMiddleware: Middleware = {
|
||||
onResponse({response}: {response: Response}) {
|
||||
if (!response.ok)
|
||||
throw new Error(`${response.url}: ${response.status} ${response.statusText}`)
|
||||
async onResponse({response}: { response: Response }) {
|
||||
if (!response.ok) {
|
||||
const body = await response.json()
|
||||
throw new Error(`${response.url}: ${response.status} ${response.statusText}`, {cause: body})
|
||||
}
|
||||
// return response untouched
|
||||
return undefined
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue