Skip to content

Commit

Permalink
make a JS-accessible error variant, though it won't be used :)
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump committed Nov 6, 2022
1 parent 06c4807 commit f7664c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions boa_engine/src/builtins/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub enum ErrorKind {
Reference,
Syntax,
Uri,
#[cfg(feature = "fuzz")]
NoInstructionsRemain,
}

/// Built-in `Error` object.
Expand Down
10 changes: 10 additions & 0 deletions boa_engine/src/context/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pub struct StandardConstructors {
syntax_error: StandardConstructor,
eval_error: StandardConstructor,
uri_error: StandardConstructor,
#[cfg(feature = "fuzz")]
no_instructions_remain_error: StandardConstructor,
aggregate_error: StandardConstructor,
map: StandardConstructor,
set: StandardConstructor,
Expand Down Expand Up @@ -156,6 +158,8 @@ impl Default for StandardConstructors {
syntax_error: StandardConstructor::default(),
eval_error: StandardConstructor::default(),
uri_error: StandardConstructor::default(),
#[cfg(feature = "fuzz")]
no_instructions_remain_error: StandardConstructor::default(),
aggregate_error: StandardConstructor::default(),
map: StandardConstructor::default(),
set: StandardConstructor::default(),
Expand Down Expand Up @@ -308,6 +312,12 @@ impl StandardConstructors {
&self.uri_error
}

#[cfg(feature = "fuzz")]
#[inline]
pub fn no_instructions_remain_error(&self) -> &StandardConstructor {
&self.no_instructions_remain_error
}

#[inline]
pub fn aggregate_error(&self) -> &StandardConstructor {
&self.aggregate_error
Expand Down
7 changes: 6 additions & 1 deletion boa_engine/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ impl JsError {
ErrorKind::Reference => JsNativeErrorKind::Reference,
ErrorKind::Syntax => JsNativeErrorKind::Syntax,
ErrorKind::Uri => JsNativeErrorKind::Uri,
#[cfg(feature = "fuzz")]
ErrorKind::NoInstructionsRemain => JsNativeErrorKind::NoInstructionsRemain,
ErrorKind::Aggregate => {
let errors = obj.get("errors", context).map_err(|e| {
TryNativeError::InaccessibleProperty {
Expand Down Expand Up @@ -634,7 +636,10 @@ impl JsNativeError {
JsNativeErrorKind::NoInstructionsRemain => {
// we can propagate out from try/catch since the catch block will also perform some
// operation
(constructors.error().prototype(), ErrorKind::Error)
(
constructors.no_instructions_remain_error().prototype(),
ErrorKind::NoInstructionsRemain,
)
}
};

Expand Down

0 comments on commit f7664c2

Please sign in to comment.