Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOBILE-4693 core: Display URL and origin for unknown url scheme errors #4281

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading