Use type alias for error.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
use crate::tokenizer::is_valid_identifier;
|
||||
use crate::types::dynamic::Variant;
|
||||
use crate::{
|
||||
Dynamic, Engine, EvalAltResult, FuncArgs, Identifier, Module, NativeCallContext, Position,
|
||||
RhaiError, RhaiResult, RhaiResultOf, StaticVec, AST,
|
||||
Dynamic, Engine, FuncArgs, Identifier, Module, NativeCallContext, Position, RhaiError,
|
||||
RhaiResult, RhaiResultOf, StaticVec, AST, ERR,
|
||||
};
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
@@ -157,7 +157,7 @@ impl FnPtr {
|
||||
let typ = engine.map_type_name(result.type_name());
|
||||
|
||||
result.try_cast().ok_or_else(|| {
|
||||
EvalAltResult::ErrorMismatchOutputType(
|
||||
ERR::ErrorMismatchOutputType(
|
||||
engine.map_type_name(type_name::<T>()).into(),
|
||||
typ.into(),
|
||||
Position::NONE,
|
||||
@@ -185,7 +185,7 @@ impl FnPtr {
|
||||
let typ = context.engine().map_type_name(result.type_name());
|
||||
|
||||
result.try_cast().ok_or_else(|| {
|
||||
EvalAltResult::ErrorMismatchOutputType(
|
||||
ERR::ErrorMismatchOutputType(
|
||||
context.engine().map_type_name(type_name::<T>()).into(),
|
||||
typ.into(),
|
||||
Position::NONE,
|
||||
@@ -255,7 +255,7 @@ impl TryFrom<Identifier> for FnPtr {
|
||||
if is_valid_identifier(value.chars()) {
|
||||
Ok(Self(value, StaticVec::new_const()))
|
||||
} else {
|
||||
Err(EvalAltResult::ErrorFunctionNotFound(value.to_string(), Position::NONE).into())
|
||||
Err(ERR::ErrorFunctionNotFound(value.to_string(), Position::NONE).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//! Module containing error definitions for the parsing process.
|
||||
|
||||
use crate::tokenizer::is_valid_identifier;
|
||||
use crate::{EvalAltResult, Position, RhaiError};
|
||||
use crate::{Position, RhaiError, ERR};
|
||||
#[cfg(feature = "no_std")]
|
||||
use core_error::Error;
|
||||
#[cfg(not(feature = "no_std"))]
|
||||
@@ -66,7 +66,7 @@ impl LexError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Type of error encountered when parsing a script.
|
||||
/// Error encountered when parsing a script.
|
||||
///
|
||||
/// Some errors never appear when certain features are turned on.
|
||||
/// They still exist so that the application can turn features on and off without going through
|
||||
@@ -317,10 +317,10 @@ impl From<ParseErrorType> for RhaiError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParseErrorType> for EvalAltResult {
|
||||
impl From<ParseErrorType> for ERR {
|
||||
#[inline(always)]
|
||||
fn from(err: ParseErrorType) -> Self {
|
||||
EvalAltResult::ErrorParsing(err, Position::NONE)
|
||||
ERR::ErrorParsing(err, Position::NONE)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,9 +331,9 @@ impl From<ParseError> for RhaiError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParseError> for EvalAltResult {
|
||||
impl From<ParseError> for ERR {
|
||||
#[inline(always)]
|
||||
fn from(err: ParseError) -> Self {
|
||||
EvalAltResult::ErrorParsing(*err.0, err.1)
|
||||
ERR::ErrorParsing(*err.0, err.1)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user