-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: reduce throwing errors #234
Conversation
if (node instanceof StringNode) return node.unescaped.value | ||
return '' | ||
}, | ||
) as [string, string] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An as cast was required here, because TypeScript cannot infer that it is a tuple of strings.
} catch (error) { | ||
throw new Error( | ||
`Failed to parse ${format} file: ${error instanceof Error ? error.message : String(error)}`, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the main motivations was to remove try-catch here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for refactoring🙏
Stop throwing errors and return the error class to the caller.
This makes it easier to take error handling into account on the CLI side. For example, adjusting the log level.