-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: Don't restrict error type for Result<T, E>
#23265
refactor: Don't restrict error type for Result<T, E>
#23265
Conversation
Could we not wrap anything in our own Error type? |
Please, elaborate on that, I'm not sure I understand what you mean |
What's wrong with using Error for everything if we can extend it however we like? |
Here is the Rubygems-related code I'm refactoring at the moment: export type VersionsResult = Result<
string[],
'unsupported-api' | 'package-not-found'
>; I think for cases like this,
But when we need it, we still can have it I guess. |
Actually, maybe the single hierarchy of errors is the good thing, I just don't want them to be descendants of |
🎉 This PR is included in version 36.7.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Changes
Error
can not be right decision for representing error results: for example, we not necessarily want to have stacktraces.There is no reason why error can't be of any type, including something lightweight like just
true
literal.This PR refactors error type and also provides some improvements for the
Result
API.Names has been aligned to
zod
schema library, as it solves very similar problems for us.Context
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: