50 lines
1 KiB
Rust
50 lines
1 KiB
Rust
use mlua::prelude::LuaError;
|
|
use ron::error::SpannedError;
|
|
|
|
pub struct JsonError(pub serde_json::Error);
|
|
pub struct RonError(pub SpannedError);
|
|
// pub struct MutexError<T>(pub PoisonError<T>);
|
|
pub struct ErrorWrapper<E>(pub E);
|
|
|
|
impl From<serde_json::Error> for JsonError {
|
|
fn from(err: serde_json::Error) -> Self {
|
|
Self(err)
|
|
}
|
|
}
|
|
|
|
impl From<JsonError> for LuaError {
|
|
fn from(err: JsonError) -> Self {
|
|
LuaError::external(err.0)
|
|
}
|
|
}
|
|
|
|
impl From<SpannedError> for RonError {
|
|
fn from(err: ron::error::SpannedError) -> Self {
|
|
Self(err)
|
|
}
|
|
}
|
|
|
|
impl From<RonError> for LuaError {
|
|
fn from(err: RonError) -> Self {
|
|
LuaError::external(err.0)
|
|
}
|
|
}
|
|
|
|
impl<E> From<E> for ErrorWrapper<E>
|
|
where
|
|
E: std::error::Error + Send + Sync
|
|
{
|
|
fn from(err: E) -> Self {
|
|
Self(err)
|
|
}
|
|
}
|
|
|
|
impl<E> From<ErrorWrapper<E>> for LuaError
|
|
where
|
|
E: std::error::Error + Send + Sync + 'static
|
|
{
|
|
fn from(err: ErrorWrapper<E>) -> Self {
|
|
LuaError::external(err.0)
|
|
}
|
|
}
|