Skip to content

Commit

Permalink
Merge pull request #4281 from dpalou/MOBILE-4693
Browse files Browse the repository at this point in the history
MOBILE-4693 core: Display URL and origin for unknown url scheme errors
  • Loading branch information
crazyserver authored Jan 9, 2025
2 parents 7211186 + 7194247 commit 84f9ea3
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/directives/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/features/login/pages/site/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -630,7 +630,7 @@ export class CoreLoginSitePage implements OnInit {
'<br><br>' + Translate.instant('core.login.youcanstillconnectwithcredentials'),
);

CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, customURL, 'CoreLoginSitePage');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/initializers/initialize-urlscheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/core/initializers/prepare-inapp-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/core/services/qrscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CoreQRScanService {
try {
await CoreCustomURLSchemes.handleCustomURL(text);
} catch (error) {
CoreCustomURLSchemes.treatHandleCustomURLError(error);
CoreCustomURLSchemes.treatHandleCustomURLError(error, text, 'CoreQRScanService');
}

return;
Expand Down
6 changes: 4 additions & 2 deletions src/core/services/urlschemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}.`,
} }));
}
}
Expand Down

0 comments on commit 84f9ea3

Please sign in to comment.