diff --git a/src/Umbraco.Web.UI.Client/src/shared/resources/apiTypeValidators.function.ts b/src/Umbraco.Web.UI.Client/src/shared/resources/apiTypeValidators.function.ts new file mode 100644 index 0000000000..091120886e --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/shared/resources/apiTypeValidators.function.ts @@ -0,0 +1,13 @@ +import type { ApiError, CancelError, CancelablePromise } from '@umbraco-cms/backoffice/backend-api'; + +export function isApiError(error: unknown): error is ApiError { + return (error as ApiError).name === 'ApiError'; +} + +export function isCancelError(error: unknown): error is CancelError { + return (error as CancelError).name === 'CancelError'; +} + +export function isCancelablePromise(promise: unknown): promise is CancelablePromise { + return (promise as CancelablePromise).cancel !== undefined; +}