Merge pull request #3725 from NoelDeMartin/MOBILE-4341

MOBILE-4341 core: Ignore native error codes in web
main
Juan Leyva 2023-07-06 17:41:20 +02:00 committed by GitHub
commit 670bb10330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 53 additions and 44 deletions

View File

@ -512,6 +512,7 @@ export class CoreWSProvider {
supportConfig: await CoreUserGuestSupportConfig.forSite(preSets.siteUrl),
};
if (CorePlatform.isMobile()) {
switch (data.status) {
case NativeHttp.ErrorCode.SSL_EXCEPTION:
options.errorcode = 'invalidcertificate';
@ -544,9 +545,16 @@ export class CoreWSProvider {
options.errorcode = 'requestprocessingfailed';
options.errorDetails = CoreTextUtils.getErrorMessageFromError(data.error) ?? 'Request processing failed';
break;
}
}
if (!options.errorcode) {
switch (data.status) {
case 404:
options.errorcode = 'endpointnotfound';
options.errorDetails = Translate.instant('core.ajaxendpointnotfound', { $a: CoreSite.MINIMUM_MOODLE_VERSION });
options.errorDetails = Translate.instant('core.ajaxendpointnotfound', {
$a: CoreSite.MINIMUM_MOODLE_VERSION,
});
break;
default: {
const details = CoreTextUtils.getErrorMessageFromError(data.error) ?? 'Unknown error';
@ -558,6 +566,7 @@ export class CoreWSProvider {
}
break;
}
}
throw new CoreAjaxError(options, 1, data.status);
});