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

feat: add error message details #922

Merged
merged 12 commits into from
Nov 28, 2024
8 changes: 7 additions & 1 deletion js/src/sdk/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@ export class CEG {
errorKey = ERROR.BACKEND.UNKNOWN;
break;
}
if (errorKey) {
if (errorKey !== ERROR.BACKEND.UNKNOWN) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition errorKey !== ERROR.BACKEND.UNKNOWN might be more clear as errorKey && errorKey !== ERROR.BACKEND.UNKNOWN to explicitly handle cases where errorKey might be undefined or null.

errorDetails = PREDEFINED_ERROR_REGISTRY[errorKey];
}else{
errorDetails = {
message: axiosError.message,
description: axiosError.response.data.message || axiosError.response.data.error || axiosError.message,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding null/undefined checks for axiosError.response and axiosError.response.data to prevent potential runtime errors. You could use optional chaining:

description: axiosError.response?.data?.message || 
             axiosError.response?.data?.error || 
             axiosError.message

possibleFix: "Please check the network connection, request parameters, and ensure the API endpoint is correct."
}
}
}

Expand Down
Loading