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

Article: Why throwing errors isn't type-safe #134

Open
JoshuaKGoldberg opened this issue Feb 12, 2024 · 0 comments
Open

Article: Why throwing errors isn't type-safe #134

JoshuaKGoldberg opened this issue Feb 12, 2024 · 0 comments
Assignees
Labels
type: article Adding a new article .mdx file

Comments

@JoshuaKGoldberg
Copy link
Collaborator

Overview

Speaking generally: https://softwareengineering.stackexchange.com/questions/189222/are-exceptions-as-control-flow-considered-a-serious-antipattern-if-so-why is a good summary of my perspective here.

I think the most salient point is the Principle of Least Astonishment. Since exceptions can't reasonably be indicated in type signatures, using exceptions requires developers memorizing which functions may throw them as a part of their "normal" flow. That's a recipe for astonishment - especially if the implicit intentional-exception-throwing contract changes unexpectedly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: article Adding a new article .mdx file
Projects
None yet
Development

No branches or pull requests

1 participant