Add custom message to _unsafeUnwrap*
Pull Request Description
Summary
This PR introduces enhancements to the error handling mechanism within the codebase by allowing custom error messages to be specified. Additionally, it updates the README documentation and adds new test cases.
Changes Made
-
README.md:
- Added documentation on how to conditionally add a custom error message that will propagate with the error object.
- Provided an example to demonstrate the usage of the custom error message with a stack trace.
-
src/_internals/error.ts:- Updated the
ErrorConfiginterface to include an optionalmessageproperty.
- Updated the
-
src/result.ts:- Modified the
_unsafeUnwrapErrmethod in theOkclass to use the custom error message if provided, otherwise, it defaults to the existing message. - Updated the
_unsafeUnwrapmethod in theErrclass to use the custom error message if provided, otherwise, it defaults to the existing message.
- Modified the
-
tests/index.test.ts:- Added test cases to verify that custom error messages are correctly included when
_unsafeUnwrapand_unsafeUnwrapErrare called with a custom message in theOkandErrclasses.
- Added test cases to verify that custom error messages are correctly included when
🦋 Changeset detected
Latest commit: 72e0a7ca0f37d2d685efd5d8117f1815a0311afd
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| neverthrow | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@supermacro rebased on to master and added a changeset. This is the same work as #558
safe to close this, right?
Ope yup sorry, this notification got buried - will update tomorrow!