You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tourmaline/src/error.rs

42 lines
939 B
Rust

use std::path::PathBuf;
use miette::Diagnostic;
use nu_protocol::ShellError;
use thiserror::Error;
pub type AppResult<T> = std::result::Result<T, AppError>;
#[derive(Error, Diagnostic, Debug)]
pub enum AppError {
#[error("Miette error")]
#[diagnostic()]
Miette(miette::Error),
#[error("Error while evaluating nu script")]
#[diagnostic()]
Nu(#[from] ShellError),
#[error("Could not find the script file")]
ScriptNotFound(PathBuf),
#[diagnostic()]
#[error("Could not parse the source file: {0}")]
ParseError(#[from] nu_parser::ParseError),
#[diagnostic()]
#[error("Could not find the main mehod in the script file {0}")]
MissingMain(PathBuf),
#[error("Failed to execute script")]
FailedToExecuteScript,
#[error("Missing config")]
MissingConfig,
}
impl From<miette::Error> for AppError {
fn from(e: miette::Error) -> Self {
Self::Miette(e)
}
}