-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional types to JS exceptions (#206)
* Add types to JS exceptions * Remove thiserror dependency * Update crates/quickjs-wasm-rs/src/js_binding/error.rs Co-authored-by: Surma <surma@surma.dev> * Update crates/core/src/globals.rs Co-authored-by: Surma <surma@surma.dev> * Fix CI failures Co-authored-by: Surma <surma@surma.dev>
- Loading branch information
1 parent
f789d96
commit 066dbb0
Showing
7 changed files
with
115 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::error::Error; | ||
use std::fmt::{self, Display, Formatter}; | ||
|
||
#[derive(Debug)] | ||
pub enum JSError { | ||
Syntax(String), | ||
Type(String), | ||
Reference(String), | ||
Range(String), | ||
Internal(String), | ||
} | ||
|
||
impl Display for JSError { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Self::Internal(msg) | ||
| Self::Range(msg) | ||
| Self::Reference(msg) | ||
| Self::Syntax(msg) | ||
| Self::Type(msg) => write!(f, "{}", msg), | ||
} | ||
} | ||
} | ||
|
||
impl Error for JSError {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod constants; | ||
pub mod context; | ||
pub mod error; | ||
pub mod exception; | ||
pub mod properties; | ||
pub mod value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters