MOBILE-4270 core: Report login errors

main
Noel De Martin 2024-03-18 09:36:45 +01:00
parent 92f65b38ad
commit 6ce688e76c
1 changed files with 12 additions and 10 deletions

View File

@ -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) {