MOBILE-3833 core: Decrease priority of redirect errors

main
Dani Palou 2022-03-07 07:53:02 +01:00
parent 8ece3c722b
commit 8ee8a0f892
2 changed files with 7 additions and 2 deletions

View File

@ -30,7 +30,7 @@ export class CoreAjaxWSError extends CoreError {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(error: any, available?: number) {
super(error.message);
super(error.message || error.error);
this.exception = error.exception;
this.errorcode = error.errorcode;

View File

@ -338,12 +338,15 @@ export class CoreSitesProvider {
}
// Service supported but an error happened. Return error.
let critical = true;
if (error.errorcode === 'codingerror') {
// This could be caused by a redirect. Check if it's the case.
const redirect = await CoreUtils.checkRedirect(siteUrl);
if (redirect) {
error.message = Translate.instant('core.login.sitehasredirect');
critical = false; // Keep checking fallback URLs.
} else {
// We can't be sure if there is a redirect or not. Display cannot connect error.
error.message = Translate.instant('core.cannotconnecttrouble');
@ -351,12 +354,14 @@ export class CoreSitesProvider {
} else if (error.errorcode === 'invalidrecord') {
// WebService not found, site not supported.
error.message = Translate.instant('core.login.invalidmoodleversion', { $a: CoreSite.MINIMUM_MOODLE_VERSION });
} else if (error.errorcode === 'redirecterrordetected') {
critical = false; // Keep checking fallback URLs.
}
return new CoreSiteError({
message: error.message,
errorcode: error.errorcode,
critical: true,
critical,
});
}