#
isGlobalDataQueriesError
Indicates whether or not an error is an instance of
GlobalDataQueriesError
errors are thrown by either the usePublicDataQueries hook or the useProtectedDataQueries hook and should usually be handled by an error boundary.
#
Reference
const result = isGlobalDataQueriesError(error);
#
Parameters
error
: AnError
instance.
#
Returns
A boolean
value indicating whether or not the error is an instance of
#
Usage
#
Handle within an error boundary
import { isGlobalDataQueriesError } from "@squide/firefly";
import { useLocation, useRouteError } from "react-router-dom";
export function ErrorBoundary() {
const error = useRouteError() as Error;
const location = useLocation();
useEffect(() => {
if (isGlobalDataQueriesError(error)) {
// ...
}
}, [location.pathname, error]);
return (
<div>
<h2>Unmanaged error</h2>
<p>An unmanaged error occurred and the application is broken, try refreshing your browser.</p>
</div>
);
}
#
Handle with a try/catch
import { isGlobalDataQueriesError } from "@squide/firefly";
try {
// ...
} catch (error: unknown) {
if (isGlobalDataQueriesError(error)) {
// ...
}
}
#
GlobalDataQueriesError
message
: The error message.errors
: An array ofError
instances.