Skip to content
Merged
Prev Previous commit
Next Next commit
fixup! review suggestions
  • Loading branch information
legendecas committed Jun 16, 2021
commit fec9561e9e14555090f6b98349d0a5bf2a5405c8
2 changes: 1 addition & 1 deletion doc/error_handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ exception.
If C++ exceptions are disabled (for more info see: [Setup](setup.md)), then the
`Napi::Error` class does not extend `std::exception`. This means that any calls to
node-addon-api function do not throw a C++ exceptions. Instead, these node-api
Comment thread
legendecas marked this conversation as resolved.
Outdated
functions that calling into JavaScript are returning with `Maybe` boxed values.
functions that call into JavaScript are returning with `Maybe` boxed values.
In that case, the calling side should convert the `Maybe` boxed values with
checks to ensure that the call did succeed and therefore no exception is pending.
If the check fails, that is to say, the returning value is _empty_, the calling
Expand Down
14 changes: 7 additions & 7 deletions doc/maybe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Maybe (template)

Class `Napi::Maybe<T>` represents an maybe empty value: every `Maybe` is either
`Just` and contains a value, or `Nothing`, and does not. `Maybe` types are very
common in node-addon-api code, as they represent the function may throw a
JavaScript exception and cause the program unable to evaluation any JavaScript
code until the exception is been handled.
Class `Napi::Maybe<T>` represents a value that may be empty: every `Maybe` is
either `Just` and contains a value, or `Nothing`, and does not. `Maybe` types
are very common in node-addon-api code, as they represent that the function may
throw a JavaScript exception and cause the program to be unable to evaluate any
JavaScript code until the exception has been handled.

Typically, the value wrapped in `Napi::Maybe<T>` is [`Napi::Value`] and its
subclasses.
Expand Down Expand Up @@ -58,7 +58,7 @@ template <typename T>
T Napi::Maybe::UnwrapOr(const T& default_value) const;
```

Return the value of type T contained in the Maybe, or using a default
Return the value of type T contained in the Maybe, or use a default
value if this Maybe is nothing (empty).

### UnwrapTo
Expand All @@ -69,6 +69,6 @@ bool Napi::Maybe::UnwrapTo() const;
```

Converts this Maybe to a value of type `T` in the `out`. If this Maybe is
nothing (empty), `false` is returned and `out is left untouched.
nothing (empty), `false` is returned and `out` is left untouched.

[`Napi::Value`]: ./value.md
Loading