From 4be465cf5a1f4614727c2317b20c21af7bbd256b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 20 Jan 2022 13:37:06 +0000 Subject: [PATCH] Extract error mesages better when throwing errors in core api client --- packages/frontend-core/src/api/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/frontend-core/src/api/index.js b/packages/frontend-core/src/api/index.js index 6f321307ae..0b91df8f76 100644 --- a/packages/frontend-core/src/api/index.js +++ b/packages/frontend-core/src/api/index.js @@ -33,16 +33,17 @@ export const createAPIClient = config => { */ const makeErrorFromResponse = async response => { // Try to read a message from the error - let message + let message = response.statusText try { const json = await response.json() - if (json?.error) { + if (json?.message) { + message = json.message + } else if (json?.error) { message = json.error } } catch (error) { // Do nothing } - console.log("building error from", response) return { message, status: response.status,