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

Improve error handling of errors thrown from functions #5

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

daniel-chambers
Copy link
Collaborator

@daniel-chambers daniel-chambers commented Jan 31, 2024

This PR improves the error handling of errors thrown from functions.

JIRA: NDC-255
GitHub: Fixes #1

Unknown Error types now have their entire causal stack trace recorded in the InternalServerError's details (previously it was only the immediate Error's stack trace).

Also, NDC TypeScript SDK error classes are now passed through transparently, and have been re-exported from the Lambda SDK. This allows function authors to throw sdk.Forbidden, sdk.Conflict, sdk.UnprocessableContent to return error details to GraphQL API clients.

For more details and examples, see the readme changes.

Copy link

@sordina sordina left a comment

Choose a reason for hiding this comment

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

Looks great!

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
ndc-lambda-sdk/src/execution.ts Outdated Show resolved Hide resolved
ndc-lambda-sdk/test/execution/execute-query.test.ts Outdated Show resolved Hide resolved
@daniel-chambers daniel-chambers merged commit 06c1674 into main Jan 31, 2024
4 checks passed
@daniel-chambers daniel-chambers deleted the error-handling branch January 31, 2024 08:22
Copy link

@sordina sordina left a comment

Choose a reason for hiding this comment

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

Great change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add docs & examples of how to throw API response errors / return non-200 responses
2 participants