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

Added diagnostics to all errors #1963

Merged
merged 34 commits into from
May 23, 2024
Merged

Conversation

arthurfiorette
Copy link
Collaborator

@arthurfiorette arthurfiorette commented May 23, 2024

This PR standardizes all errors thrown by this library, which helps every package that uses this code underneath, as well with the end-user using this CLI.

As every errors extends from TJSGError, every error may have a .diagnostic which can be formatted by the ts.formatDiagnosticsWithColorAndContext function.

For example, when having a typecheck error, this is what was shown:

image

VS what is now:

image

Or, for example, when a node cannot be parsed (I faked the error):

image

VS what is now:

image


All errors are serializable and can contain useful information.

In non tty environment, such as CI environments, thrown errors doesn't emit ANSI color codes or anything might blowup logs with useless information.

image

Version

Published prerelease version: v2.3.0-next.0

Changelog

🚀 Enhancement

Authors: 1

📦 Published PR as canary version: 2.3.0--canary.1963.49df2de.0

✨ Test out this PR locally via:

npm install ts-json-schema-generator@2.3.0--canary.1963.49df2de.0
# or 
yarn add ts-json-schema-generator@2.3.0--canary.1963.49df2de.0

@arthurfiorette arthurfiorette self-assigned this May 23, 2024
src/Error/Errors.ts Outdated Show resolved Hide resolved
@arthurfiorette
Copy link
Collaborator Author

Next up, I was thinking of rewriting the CLI to use oclif. I did the same thing with kitajs and it's awesome. It auto generates cli documentation, provides autocompletions, automatically creates help commands, detect cli updates and much more automatically.

Sample of kitajs cli autocomplete:

image

Sample of kitajs cli help:

image

What do you think?

@domoritz
Copy link
Member

Better cli sounds great

@domoritz
Copy link
Member

I gave you write permissions to the repo so you can make PRs from internal branches and merge PRs when they are done.

@arthurfiorette
Copy link
Collaborator Author

thanks!

Copy link

github-actions bot commented Jun 5, 2024

🚀 PR was released in v2.3.0 🚀

@github-actions github-actions bot added released This issue/pull request has been released. and removed prerelease labels Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants