diff --git a/packages/react-components/src/echarts/extensions/trendCursors/echartsActions/extension.ts b/packages/react-components/src/echarts/extensions/trendCursors/echartsActions/extension.ts index 92619d888..d4c55f840 100644 --- a/packages/react-components/src/echarts/extensions/trendCursors/echartsActions/extension.ts +++ b/packages/react-components/src/echarts/extensions/trendCursors/echartsActions/extension.ts @@ -31,6 +31,7 @@ export const actionExtension: any = ( if ( !event || !trendCursor || + !api || ecmodel.getOption().appKitChartId !== chartId || getTrendCursors(ecmodel).length > 4 ) @@ -47,7 +48,8 @@ export const actionExtension: any = ( registers.registerAction( RemoveNearestTrendCursorActionType, ({ event, chartId }: RemoveTrendCursorAction, ecmodel, api) => { - if (!event || ecmodel.getOption().appKitChartId !== chartId) return; + if (!event || !api || ecmodel.getOption().appKitChartId !== chartId) + return; const date = getXAxisDataValue(event.offsetX, api); @@ -67,7 +69,12 @@ export const actionExtension: any = ( registers.registerAction( CopyTrendCursorActionType, ({ event, chartId }: CopyTrendCursorAction, ecmodel, api) => { - if (!event || !chartId || ecmodel.getOption().appKitChartId !== chartId) + if ( + !event || + !chartId || + !api || + ecmodel.getOption().appKitChartId !== chartId + ) return; const date = getXAxisDataValue(event.offsetX, api); diff --git a/packages/source-iotsitewise/src/time-series-data/client/batchGetAggregatedPropertyDataPoints.ts b/packages/source-iotsitewise/src/time-series-data/client/batchGetAggregatedPropertyDataPoints.ts index 96855d02e..4906b43a5 100644 --- a/packages/source-iotsitewise/src/time-series-data/client/batchGetAggregatedPropertyDataPoints.ts +++ b/packages/source-iotsitewise/src/time-series-data/client/batchGetAggregatedPropertyDataPoints.ts @@ -5,6 +5,10 @@ import { TimeOrdering, type BatchGetAssetPropertyAggregatesErrorEntry, type BatchGetAssetPropertyAggregatesSuccessEntry, + type IoTSiteWiseServiceException, + AccessDeniedException, + InvalidRequestException, + ResourceNotFoundException, } from '@aws-sdk/client-iotsitewise'; import { aggregateToDataPoint } from '../util/toDataPoint'; import { dataStreamFromSiteWise } from '../dataStreamFromSiteWise'; @@ -164,14 +168,20 @@ const sendRequest = ({ }); } }) - .catch((e) => { - Object.entries(callbackCache).forEach(([entryId, { onError }]) => { - onError({ - entryId, - errorCode: e.$metadata?.httpStatusCode, - errorMessage: e.message, + .catch((e: IoTSiteWiseServiceException) => { + if ( + e instanceof AccessDeniedException || + e instanceof InvalidRequestException || + e instanceof ResourceNotFoundException + ) { + Object.entries(callbackCache).forEach(([entryId, { onError }]) => { + onError({ + entryId, + errorCode: e.name, + errorMessage: e.message, + }); }); - }); + } }); }; diff --git a/packages/source-iotsitewise/src/time-series-data/client/batchGetHistoricalPropertyDataPoints.ts b/packages/source-iotsitewise/src/time-series-data/client/batchGetHistoricalPropertyDataPoints.ts index ea4e2436f..fa10636a6 100644 --- a/packages/source-iotsitewise/src/time-series-data/client/batchGetHistoricalPropertyDataPoints.ts +++ b/packages/source-iotsitewise/src/time-series-data/client/batchGetHistoricalPropertyDataPoints.ts @@ -4,6 +4,10 @@ import { TimeOrdering, type BatchGetAssetPropertyValueHistoryErrorEntry, type BatchGetAssetPropertyValueHistorySuccessEntry, + type IoTSiteWiseServiceException, + AccessDeniedException, + InvalidRequestException, + ResourceNotFoundException, } from '@aws-sdk/client-iotsitewise'; import { toDataPoint } from '../util/toDataPoint'; import { dataStreamFromSiteWise } from '../dataStreamFromSiteWise'; @@ -159,14 +163,20 @@ const sendRequest = ({ }); } }) - .catch((e) => { - Object.entries(callbackCache).forEach(([entryId, { onError }]) => { - onError({ - entryId, - errorCode: e.$metadata?.httpStatusCode, - errorMessage: e.message, + .catch((e: IoTSiteWiseServiceException) => { + if ( + e instanceof AccessDeniedException || + e instanceof InvalidRequestException || + e instanceof ResourceNotFoundException + ) { + Object.entries(callbackCache).forEach(([entryId, { onError }]) => { + onError({ + entryId, + errorCode: e.name, + errorMessage: e.message, + }); }); - }); + } }); }; diff --git a/packages/source-iotsitewise/src/time-series-data/client/batchGetLatestPropertyDataPoints.ts b/packages/source-iotsitewise/src/time-series-data/client/batchGetLatestPropertyDataPoints.ts index fe8f4cc3c..cc6f761fc 100644 --- a/packages/source-iotsitewise/src/time-series-data/client/batchGetLatestPropertyDataPoints.ts +++ b/packages/source-iotsitewise/src/time-series-data/client/batchGetLatestPropertyDataPoints.ts @@ -3,6 +3,10 @@ import { type IoTSiteWiseClient, type BatchGetAssetPropertyValueErrorEntry, type BatchGetAssetPropertyValueSuccessEntry, + type IoTSiteWiseServiceException, + AccessDeniedException, + InvalidRequestException, + ResourceNotFoundException, } from '@aws-sdk/client-iotsitewise'; import { toDataPoint } from '../util/toDataPoint'; import { dataStreamFromSiteWise } from '../dataStreamFromSiteWise'; @@ -139,14 +143,20 @@ const sendRequest = ({ }); } }) - .catch((e) => { - Object.entries(callbackCache).forEach(([entryId, { onError }]) => { - onError({ - entryId, - errorCode: e.$metadata?.httpStatusCode, - errorMessage: e.message, + .catch((e: IoTSiteWiseServiceException) => { + if ( + e instanceof AccessDeniedException || + e instanceof InvalidRequestException || + e instanceof ResourceNotFoundException + ) { + Object.entries(callbackCache).forEach(([entryId, { onError }]) => { + onError({ + entryId, + errorCode: e.name, + errorMessage: e.message, + }); }); - }); + } }); };