mirror of
https://github.com/tale/headplane.git
synced 2026-08-13 07:06:51 +00:00
feat: track headscale acl response changes
This commit is contained in:
@@ -44,6 +44,13 @@ export function isConnectionError(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if an error is a DataUnauthorizedError.
|
||||
* This checks if the error has a `data` property with a `statusCode` of 401.
|
||||
*
|
||||
* @param error - The error to check.
|
||||
* @returns True if the error is a DataUnauthorizedError, false otherwise.
|
||||
*/
|
||||
export function isDataUnauthorizedError(error: unknown): boolean {
|
||||
return (
|
||||
error != null &&
|
||||
@@ -55,3 +62,23 @@ export function isDataUnauthorizedError(error: unknown): boolean {
|
||||
error.data.statusCode === 401
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard to check if an error is a DataWithResponseInit wrapping a
|
||||
* HeadscaleAPIError. This is used in loaders/actions to handle errors thrown by
|
||||
* `data()` before they reach the ErrorBoundary.
|
||||
*
|
||||
* @param error - The error to check.
|
||||
* @returns True if the error is a DataWithResponseInit containing a
|
||||
* HeadscaleAPIError, false otherwise.
|
||||
*/
|
||||
export function isDataWithApiError(
|
||||
error: unknown,
|
||||
): error is { data: HeadscaleAPIError } {
|
||||
return (
|
||||
error != null &&
|
||||
typeof error === 'object' &&
|
||||
'data' in error &&
|
||||
isApiError(error.data)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user