Skip to content

Commit

Permalink
fix: rustler update to v0.35.0
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrizio Sestito <[email protected]>
  • Loading branch information
fabriziosestito committed Oct 19, 2024
1 parent 2748ce4 commit 26ce19b
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 209 deletions.
107 changes: 57 additions & 50 deletions native/rhai_rustler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions native/rhai_rustler/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::panic::RefUnwindSafe;

use thiserror::Error;

use rhai::{EvalAltResult, ParseError};
Expand Down Expand Up @@ -49,10 +51,22 @@ pub enum ScopeError {
ErrorCannotUpdateValueOfConstant,
}

#[derive(Error, Debug)]
#[error(transparent)]
pub struct EvaluationError(pub Box<EvalAltResult>);

impl RefUnwindSafe for EvaluationError {}

impl From<Box<EvalAltResult>> for RhaiRustlerError {
fn from(err: Box<EvalAltResult>) -> Self {
RhaiRustlerError::EvaluationError(EvaluationError(err))
}
}

#[derive(Error, Debug)]
pub enum RhaiRustlerError {
#[error("Error in evaluation: {0}.")]
EvalAltResult(#[from] Box<EvalAltResult>),
EvaluationError(#[from] EvaluationError),
#[error("Error when parsing a script: {0}.")]
ParseError(#[from] ParseError),
#[error("Error when accessing a scope: {0}.")]
Expand All @@ -64,7 +78,7 @@ pub enum RhaiRustlerError {
impl Encoder for RhaiRustlerError {
fn encode<'a>(&self, env: Env<'a>) -> Term<'a> {
match self {
RhaiRustlerError::EvalAltResult(err) => {
RhaiRustlerError::EvaluationError(EvaluationError(err)) => {
let error_atom = match err.unwrap_inner() {
EvalAltResult::ErrorSystem(_, _) => atoms::system(),
EvalAltResult::ErrorParsing(_, _) => atoms::parsing(),
Expand Down
Loading

0 comments on commit 26ce19b

Please sign in to comment.