File tree Expand file tree Collapse file tree 1 file changed +7
-20
lines changed
blog/2024-12-05-boa-release-020 Expand file tree Collapse file tree 1 file changed +7
-20
lines changed Original file line number Diff line number Diff line change @@ -60,26 +60,13 @@ Embedders can now create native errors in Rust and pass them into the JavaScript
60
60
The below example creates a new `JsError` from a Rust standard error [`err`](https://doc.rust-lang.org/std/error/trait.Error.html). This will create a new `JsNativeError` with the message of the standard error.
61
61
62
62
````rust
63
- /// # Examples
64
- ///
65
- /// ```
66
- /// # use boa_engine::JsError;
67
- /// let error = std::io::Error::new(std::io::ErrorKind::Other, " oh no!" );
68
- /// let js_error: JsError = JsError::from_rust(error);
69
- ///
70
- /// assert_eq!(js_error.as_native().unwrap().message(), " oh no!" );
71
- /// assert!(js_error.as_native().unwrap().cause().is_none());
72
- /// ```
73
- #[must_use]
74
- pub fn from_rust(err: impl error::Error) -> Self {
75
- let mut native_err = JsNativeError ::error ().with_message (err .to_string ());
76
- if let Some (source ) = err .source () {
77
- native_err = native_err .with_cause (Self ::from_rust (source ));
78
- }
79
-
80
- Self ::from_native (native_err )
81
- }
82
- ````
63
+ use boa_engine::JsError;
64
+
65
+ let error = std::io::Error::new(std::io::ErrorKind::Other, " oh no!" );
66
+ let js_error: JsError = JsError::from_rust(error);
67
+
68
+ assert_eq!(js_error.as_native().unwrap().message(), " oh no!" );
69
+ assert!(js_error.as_native().unwrap().cause().is_none());
83
70
84
71
## Boa Runtime
85
72
You can’t perform that action at this time.
0 commit comments