From f247d7150ed47845d1099ced248cd96ecac331e2 Mon Sep 17 00:00:00 2001 From: Warren Parad Date: Thu, 14 Dec 2023 00:14:44 +0100 Subject: [PATCH] Improve http error handling on error conditions. --- CHANGELOG.md | 1 + src/httpClient.js | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd35d46..947ffc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ This is the changelog for [Authress Login](readme.md). ## 2.3 ## * Add MFA device methods. +* Improve http error handling when there is an issue authenticating. ## 2.2 ## * Automatically retry on network connection issues. diff --git a/src/httpClient.js b/src/httpClient.js index 65fee8a..e60757f 100644 --- a/src/httpClient.js +++ b/src/httpClient.js @@ -128,11 +128,13 @@ class HttpClient { this.logger[level]({ title: message, online: navigator.onLine, method, url, status, data, headers, error, resolvedError }); } - error.url = url; - error.status = status; - error.data = resolvedError; - error.headers = error.response.headers || error.headers; - throw error; + const httpError = { + url: url, + status: status, + data: resolvedError, + headers: error.response.headers || error.headers + }; + throw httpError; } } }