Skip to content
Open
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
28 changes: 27 additions & 1 deletion client-app/core/api/graphql/config/error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
import { onError } from "@apollo/client/link/error";
import { useAppInsights } from "vue3-application-insights";
import { errorHandler } from "@/core/api/common";
import { GraphQLErrorCode } from "@/core/api/graphql/enums";
import { hasErrorCode, toServerError } from "@/core/api/graphql/utils";
import { Logger } from "@/core/utilities";
import { TabsType, userLockedEvent, passwordExpiredEvent, useBroadcast, graphqlErrorEvent } from "@/shared/broadcast";

export const errorHandlerLink = onError(({ networkError, graphQLErrors }) => {
export const errorHandlerLink = onError(({ networkError, graphQLErrors, operation }) => {
const broadcast = useBroadcast();
const appInsights = useAppInsights();

errorHandler(toServerError(networkError, graphQLErrors));

if (networkError instanceof Error && networkError.name === "AbortError" && networkError.message.includes("timeout")) {
const errorDetails = {
name: "RequestTimeout",
message: networkError.message,
operation: operation.operationName,
variables: operation.variables,
timestamp: new Date().toISOString(),
};

Logger.error("Request timeout:", errorDetails);

if (appInsights) {
appInsights.trackException({
error: networkError,
properties: {
operationName: operation.operationName,
variables: JSON.stringify(operation.variables),
type: "RequestTimeout",
},
});
}
}

const userLockedError = hasErrorCode(graphQLErrors, GraphQLErrorCode.UserLocked);
const passwordExpired = hasErrorCode(graphQLErrors, GraphQLErrorCode.PasswordExpired);

Expand Down
Loading