Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: client side errors from unexpected null/undefined values #3129

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const actionExtension: any = (
if (
!event ||
!trendCursor ||
!api ||
ecmodel.getOption().appKitChartId !== chartId ||
getTrendCursors(ecmodel).length > 4
)
Expand All @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
});
});
});
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
});
});
});
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
});
});
});
}
});
};

Expand Down
Loading