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

refactor: reduce throwing errors #234

Merged
merged 4 commits into from
Dec 13, 2024
Merged

refactor: reduce throwing errors #234

merged 4 commits into from
Dec 13, 2024

Conversation

MH4GF
Copy link
Member

@MH4GF MH4GF commented Dec 12, 2024

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.

@MH4GF MH4GF temporarily deployed to preview - erd-sample December 12, 2024 12:32 — with GitHub Actions Inactive
@MH4GF MH4GF changed the title reduce throw error refactor: reduce throwing errors Dec 12, 2024
if (node instanceof StringNode) return node.unescaped.value
return ''
},
) as [string, string]
Copy link
Member Author

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)}`,
)
Copy link
Member Author

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.

@MH4GF MH4GF marked this pull request as ready for review December 12, 2024 12:36
@MH4GF MH4GF requested a review from a team as a code owner December 12, 2024 12:37
@MH4GF MH4GF requested review from hoshinotsuyoshi, FunamaYukina, junkisai and sasamuku and removed request for a team December 12, 2024 12:37
Copy link
Member

@sasamuku sasamuku left a 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🙏

@sasamuku sasamuku added this pull request to the merge queue Dec 13, 2024
Merged via the queue into main with commit cc82f8f Dec 13, 2024
13 checks passed
@sasamuku sasamuku deleted the reduce-throw-error branch December 13, 2024 05:25
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.

2 participants