Skip to content

Commit

Permalink
Document better what should be done to avoid unwrapErr (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstasiak authored Jul 5, 2024
1 parent 295149a commit e69e293
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/reference/api/result.rst
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ Example:
Returns the contained ``Err`` value.
Because this function may throw, its use is generally discouraged.
Instead, prefer to handle the ``Ok`` case explicitly.
Instead, prefer to handle the ``Ok`` case explicitly and access the `error`_ property
directly.

Throws if the value is an ``Ok``, with a message provided by the ``Ok``'s value and
`cause`_ set to the value.
Expand Down
3 changes: 2 additions & 1 deletion src/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ interface BaseResult<T, E> extends Iterable<T extends Iterable<infer U> ? U : ne
/**
* Returns the contained `Err` value.
* Because this function may throw, its use is generally discouraged.
* Instead, prefer to handle the `Ok` case explicitly.
* Instead, prefer to handle the `Ok` case explicitly and access the `error` property
* directly.
*
* Throws if the value is an `Ok`, with a message provided by the `Ok`'s value and
* [`cause'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause)
Expand Down

0 comments on commit e69e293

Please sign in to comment.