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 unhandled error to append useful information #2063

Merged
merged 5 commits into from
Sep 7, 2024

Conversation

arthurfiorette
Copy link
Collaborator

@arthurfiorette arthurfiorette commented Sep 7, 2024

This PR wraps every interaction with node parsers and type formatters aroung a catch that rethrows an UnhandledError.

This way, for example, if BooleanTypeNodeParser had a code like this:

public createType(node: ts.KeywordTypeNode, context: Context): BaseType {
    let a = undefined;
    a.toString();
    return new BooleanType();
}

Instead of just seeing: (Which almost always doesn't say anything useful)

TypeError: Cannot read properties of undefined (reading 'toString')
    at BooleanTypeNodeParser.createType (/ts-json-schema-generator/dist/src/NodeParser/BooleanTypeNodeParser.js:13:11)

we can see which part of user's code triggered this error.

image

This is a big improvement to users, so they can debug issues themselves with more clarity of what is breaking and for us in reported issues to reduce the number of issues where the only useful information is the stack trace, like #1861 or #1756 and many others I'm sure you've already saw.

📦 Published PR as canary version: 2.3.1--canary.2063.403e019.0

✨ Test out this PR locally via:

npm install [email protected]
# or 
yarn add [email protected]

Version

Published prerelease version: v2.4.0-next.4

Changelog

🎉 This release contains work from a new contributor! 🎉

Thank you, Bence Balogh (@baloghbence0915), for all your work!

🚀 Enhancement

🐛 Bug Fix

⚠️ Pushed to next

🔩 Dependency Updates

Authors: 4

@arthurfiorette arthurfiorette merged commit d69f592 into next Sep 7, 2024
3 checks passed
@arthurfiorette arthurfiorette deleted the arthur/unhandled branch September 7, 2024 15:50
Copy link

github-actions bot commented Sep 7, 2024

🚀 PR was released in v2.4.0-next.4 🚀

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

Successfully merging this pull request may close these issues.

2 participants