package.esm2022.src.navigation_canceling_error.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of router Show documentation
Show all versions of router Show documentation
Angular - the routing library
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { NavigationCancellationCode } from './events';
import { isUrlTree } from './url_tree';
export const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
export function redirectingNavigationError(urlSerializer, redirect) {
const { redirectTo, navigationBehaviorOptions } = isUrlTree(redirect)
? { redirectTo: redirect, navigationBehaviorOptions: undefined }
: redirect;
const error = navigationCancelingError(ngDevMode && `Redirecting to "${urlSerializer.serialize(redirectTo)}"`, NavigationCancellationCode.Redirect);
error.url = redirectTo;
error.navigationBehaviorOptions = navigationBehaviorOptions;
return error;
}
export function navigationCancelingError(message, code) {
const error = new Error(`NavigationCancelingError: ${message || ''}`);
error[NAVIGATION_CANCELING_ERROR] = true;
error.cancellationCode = code;
return error;
}
export function isRedirectingNavigationCancelingError(error) {
return (isNavigationCancelingError(error) &&
isUrlTree(error.url));
}
export function isNavigationCancelingError(error) {
return !!error && error[NAVIGATION_CANCELING_ERROR];
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF2aWdhdGlvbl9jYW5jZWxpbmdfZXJyb3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9yb3V0ZXIvc3JjL25hdmlnYXRpb25fY2FuY2VsaW5nX2Vycm9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQywwQkFBMEIsRUFBQyxNQUFNLFVBQVUsQ0FBQztBQUVwRCxPQUFPLEVBQUMsU0FBUyxFQUF5QixNQUFNLFlBQVksQ0FBQztBQUU3RCxNQUFNLENBQUMsTUF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