Merge pull request #4281 from dpalou/MOBILE-4693

MOBILE-4693 core: Display URL and origin for unknown url scheme errors
main
Pau Ferrer Ocaña 2025-01-09 14:01:08 +01:00 committed by GitHub
commit 84f9ea395f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 8 deletions

View File

@ -140,7 +140,7 @@ export class CoreLinkDirective implements OnInit {
try {
await CoreCustomURLSchemes.handleCustomURL(href);
} catch (error) {
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, href, 'CoreLinkDirective');
}
return;

View File

@ -564,7 +564,7 @@ export class CoreLoginSitePage implements OnInit {
// An error ocurred, but it's an authentication URL and we have the site URL.
this.treatErrorInAuthenticationCustomURL(text, error);
} else {
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, text, 'CoreLoginSitePage');
}
}
@ -630,7 +630,7 @@ export class CoreLoginSitePage implements OnInit {
'<br><br>' + Translate.instant('core.login.youcanstillconnectwithcredentials'),
);
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, customURL, 'CoreLoginSitePage');
}
/**

View File

@ -42,7 +42,7 @@ export default async function(): Promise<void> {
CoreEvents.trigger(CoreEvents.APP_LAUNCHED_URL, { url });
CoreCustomURLSchemes.handleCustomURL(url).catch((error) => {
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, url, 'handleOpenURL');
});
});
};

View File

@ -41,7 +41,7 @@ export default function(): void {
if (CoreCustomURLSchemes.isCustomURL(url)) {
// Close the browser if it's a valid SSO URL.
CoreCustomURLSchemes.handleCustomURL(url).catch((error) => {
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, url, 'InAppBrowser');
});
CoreOpener.closeInAppBrowser();

View File

@ -77,7 +77,7 @@ export class CoreQRScanService {
try {
await CoreCustomURLSchemes.handleCustomURL(text);
} catch (error) {
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, text, 'CoreQRScanService');
}
return;

View File

@ -520,8 +520,10 @@ export class CoreCustomURLSchemesProvider {
* Treat error returned by handleCustomURL.
*
* @param error Error data.
* @param url The URL that caused the error.
* @param origin Origin of the treat handle error call.
*/
treatHandleCustomURLError(error: CoreCustomURLSchemesHandleError): void {
treatHandleCustomURLError(error: CoreCustomURLSchemesHandleError, url = '', origin = 'unknown'): void {
if (error.error === 'Duplicated') {
// Duplicated request
} else if (CoreWSError.isWebServiceError(error.error) && error.data && error.data.isSSOToken) {
@ -531,7 +533,7 @@ export class CoreCustomURLSchemesProvider {
} else {
CoreDomUtils.showErrorModal(error.error ?? new CoreError(Translate.instant('core.login.invalidsite'), { debug: {
code: 'unknownerror',
details: 'Unknown error when treating a URL scheme.',
details: `Unknown error when treating a URL scheme.<br><br>Origin: ${origin}.<br><br>URL: ${url}.`,
} }));
}
}