use std::{fmt, result};
use serde::{de, ser};
#[derive(thiserror::Error)]
pub enum Error {
#[error(transparent)]
Syntax(#[from] nt_syntax::SyntaxError),
#[error("{0}")]
Msg(String),
}
impl Error {
pub fn msg(msg: impl Into<String>) -> Self {
Self::Msg(msg.into())
}
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl de::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Self::Msg(msg.to_string())
}
}
impl ser::Error for Error {
fn custom<T: fmt::Display>(msg: T) -> Self {
Self::Msg(msg.to_string())
}
}
pub type Result<T> = result::Result<T, Error>;