silence error handler

This commit is contained in:
Nate Kelley 2025-09-20 14:16:04 -06:00
parent 3bff20c8e0
commit 273008adc6
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 39 additions and 6 deletions

View File

@ -186,6 +186,8 @@ export const useGetMetricData = <TData = BusterMetricDataExtended>(
return useQuery({ return useQuery({
...metricsQueryKeys.metricsGetData(id || '', versionNumberProp || 'LATEST'), ...metricsQueryKeys.metricsGetData(id || '', versionNumberProp || 'LATEST'),
queryFn, queryFn,
select: params?.select,
...params,
enabled: () => { enabled: () => {
return ( return (
!!id && !!id &&
@ -193,11 +195,10 @@ export const useGetMetricData = <TData = BusterMetricDataExtended>(
!isErrorMetric && !isErrorMetric &&
!!metricId && !!metricId &&
!!dataUpdatedAt && !!dataUpdatedAt &&
!!selectedVersionNumber !!selectedVersionNumber &&
params?.enabled !== false
); );
}, },
select: params?.select,
...params,
}); });
}; };

View File

@ -9,6 +9,7 @@ import {
import { create } from 'mutative'; import { create } from 'mutative';
import { collectionQueryKeys } from '@/api/query_keys/collection'; import { collectionQueryKeys } from '@/api/query_keys/collection';
import { reportsQueryKeys } from '@/api/query_keys/reports'; import { reportsQueryKeys } from '@/api/query_keys/reports';
import { silenceAssetErrors } from '@/api/repsonse-helpers/silenece-asset-errors';
import type { RustApiError } from '../../errors'; import type { RustApiError } from '../../errors';
import { import {
useAddAssetToCollection, useAddAssetToCollection,
@ -72,7 +73,6 @@ export const prefetchGetReport = async (
report_version_number: number | undefined report_version_number: number | undefined
) => { ) => {
const version_number = report_version_number || 'LATEST'; const version_number = report_version_number || 'LATEST';
const queryKey = reportsQueryKeys.reportsGetReport(reportId, version_number)?.queryKey; const queryKey = reportsQueryKeys.reportsGetReport(reportId, version_number)?.queryKey;
const existingData = queryClient.getQueryData(queryKey); const existingData = queryClient.getQueryData(queryKey);
if (!existingData) { if (!existingData) {
@ -83,6 +83,7 @@ export const prefetchGetReport = async (
id: reportId, id: reportId,
version_number: typeof version_number === 'number' ? version_number : undefined, version_number: typeof version_number === 'number' ? version_number : undefined,
}), }),
retry: silenceAssetErrors,
}); });
} }
@ -116,6 +117,7 @@ export const useGetReport = <T = GetReportResponse>(
enabled: !!id, enabled: !!id,
select: options?.select, select: options?.select,
...options, ...options,
retry: silenceAssetErrors,
}); });
}; };

View File

@ -0,0 +1,20 @@
import { openErrorNotification } from '@/context/BusterNotifications';
import type { RustApiError } from '../errors';
export const silenceAssetErrors = (_count: number, error: RustApiError): boolean => {
if (error.status === 418) {
return false;
}
if (error.status === 410) {
return false;
}
if (error.status === 403) {
return false;
}
openErrorNotification(error);
return false;
};

View File

@ -16,7 +16,7 @@ export const AppAssetNotFound: React.FC<{
console.info('AppAssetNotFound for asset:', assetId, 'and type:', type); console.info('AppAssetNotFound for asset:', assetId, 'and type:', type);
}); });
return ( return (
<div className="flex h-[85vh] w-full flex-col items-center justify-center space-y-6"> <div className="flex h-full w-full flex-col items-center justify-center space-y-6 bg-background">
<BusterLogo className="h-16 w-16" /> <BusterLogo className="h-16 w-16" />
<div className="max-w-[550px] text-center"> <div className="max-w-[550px] text-center">

View File

@ -50,7 +50,7 @@ export const AppNoPageAccess: React.FC<{
}, [isAnonymousUser]); }, [isAnonymousUser]);
return ( return (
<div className="flex h-[85vh] w-full flex-col items-center justify-center space-y-6"> <div className="flex h-full w-full flex-col items-center justify-center space-y-6 bg-background">
<BusterLogo className="h-16 w-16" /> <BusterLogo className="h-16 w-16" />
<div className="max-w-[550px] text-center"> <div className="max-w-[550px] text-center">

View File

@ -59,6 +59,16 @@ const getAssetAccess = (
}; };
} }
if (typeof error?.status === 'number') {
return {
hasAccess: false,
passwordRequired: false,
isPublic: false,
isDeleted: false,
isFetched,
};
}
return { return {
hasAccess: true, hasAccess: true,
passwordRequired: false, passwordRequired: false,