mirror of https://github.com/buster-so/buster.git
silence error handler
This commit is contained in:
parent
3bff20c8e0
commit
273008adc6
|
@ -186,6 +186,8 @@ export const useGetMetricData = <TData = BusterMetricDataExtended>(
|
|||
return useQuery({
|
||||
...metricsQueryKeys.metricsGetData(id || '', versionNumberProp || 'LATEST'),
|
||||
queryFn,
|
||||
select: params?.select,
|
||||
...params,
|
||||
enabled: () => {
|
||||
return (
|
||||
!!id &&
|
||||
|
@ -193,11 +195,10 @@ export const useGetMetricData = <TData = BusterMetricDataExtended>(
|
|||
!isErrorMetric &&
|
||||
!!metricId &&
|
||||
!!dataUpdatedAt &&
|
||||
!!selectedVersionNumber
|
||||
!!selectedVersionNumber &&
|
||||
params?.enabled !== false
|
||||
);
|
||||
},
|
||||
select: params?.select,
|
||||
...params,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
import { create } from 'mutative';
|
||||
import { collectionQueryKeys } from '@/api/query_keys/collection';
|
||||
import { reportsQueryKeys } from '@/api/query_keys/reports';
|
||||
import { silenceAssetErrors } from '@/api/repsonse-helpers/silenece-asset-errors';
|
||||
import type { RustApiError } from '../../errors';
|
||||
import {
|
||||
useAddAssetToCollection,
|
||||
|
@ -72,7 +73,6 @@ export const prefetchGetReport = async (
|
|||
report_version_number: number | undefined
|
||||
) => {
|
||||
const version_number = report_version_number || 'LATEST';
|
||||
|
||||
const queryKey = reportsQueryKeys.reportsGetReport(reportId, version_number)?.queryKey;
|
||||
const existingData = queryClient.getQueryData(queryKey);
|
||||
if (!existingData) {
|
||||
|
@ -83,6 +83,7 @@ export const prefetchGetReport = async (
|
|||
id: reportId,
|
||||
version_number: typeof version_number === 'number' ? version_number : undefined,
|
||||
}),
|
||||
retry: silenceAssetErrors,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -116,6 +117,7 @@ export const useGetReport = <T = GetReportResponse>(
|
|||
enabled: !!id,
|
||||
select: options?.select,
|
||||
...options,
|
||||
retry: silenceAssetErrors,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
|
@ -16,7 +16,7 @@ export const AppAssetNotFound: React.FC<{
|
|||
console.info('AppAssetNotFound for asset:', assetId, 'and type:', type);
|
||||
});
|
||||
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" />
|
||||
|
||||
<div className="max-w-[550px] text-center">
|
||||
|
|
|
@ -50,7 +50,7 @@ export const AppNoPageAccess: React.FC<{
|
|||
}, [isAnonymousUser]);
|
||||
|
||||
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" />
|
||||
|
||||
<div className="max-w-[550px] text-center">
|
||||
|
|
|
@ -59,6 +59,16 @@ const getAssetAccess = (
|
|||
};
|
||||
}
|
||||
|
||||
if (typeof error?.status === 'number') {
|
||||
return {
|
||||
hasAccess: false,
|
||||
passwordRequired: false,
|
||||
isPublic: false,
|
||||
isDeleted: false,
|
||||
isFetched,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
hasAccess: true,
|
||||
passwordRequired: false,
|
||||
|
|
Loading…
Reference in New Issue