From de1451def8d79da5ecb7758dea28fa07353fc37a Mon Sep 17 00:00:00 2001 From: Akash Kava <39438041+ackava@users.noreply.github.com> Date: Wed, 8 May 2024 20:21:07 +0530 Subject: [PATCH] Added title check --- src/services/FetchBuilder.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/FetchBuilder.ts b/src/services/FetchBuilder.ts index 53a6ef0f..6571fbac 100644 --- a/src/services/FetchBuilder.ts +++ b/src/services/FetchBuilder.ts @@ -149,7 +149,11 @@ export default class FetchBuilder { const type = r.headers.get("content-type"); if (/\/json/i.test(type)) { const json = await r.json(); - throw new JsonError(`Failed for ${this.request.url}`, json); + throw new JsonError(json.title + ?? json.detail + ?? json.message + ?? json.exceptionMessage + ?? "Json Server Error", json); } const text = await r.text(); throw new Error(`Failed for ${this.request.url}\n${text}`);