From 6ce688e76ca31eef1ff990583528a8cb9a9d5fa6 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Mon, 18 Mar 2024 09:36:45 +0100 Subject: [PATCH] MOBILE-4270 core: Report login errors --- src/core/services/sites.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index d16dbb053..00e0e400b 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -499,19 +499,21 @@ export class CoreSitesProvider { try { data = await firstValueFrom(Http.post(loginUrl, params).pipe(timeout(CoreWS.getRequestTimeout()))); } catch (error) { - throw new CoreError( - this.isLoggedIn() - ? Translate.instant('core.siteunavailablehelp', { site: this.currentSite?.siteUrl }) - : Translate.instant('core.sitenotfoundhelp'), - ); + throw this.createCannotConnectLoginError(siteUrl, { + debug: { + code: 'logintokenerror', + details: error.message, + }, + }); } if (data === undefined) { - throw new CoreError( - this.isLoggedIn() - ? Translate.instant('core.siteunavailablehelp', { site: this.currentSite?.siteUrl }) - : Translate.instant('core.sitenotfoundhelp'), - ); + throw this.createCannotConnectLoginError(siteUrl, { + debug: { + code: 'logintokenempty', + details: 'The request to /login/token.php returned an empty response', + }, + }); } if (data.token !== undefined) {