diff options
Diffstat (limited to 'src/common/error.rs')
-rw-r--r-- | src/common/error.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/error.rs b/src/common/error.rs index f3f3023ceaf8..51575a895e91 100644 --- a/src/common/error.rs +++ b/src/common/error.rs @@ -2,7 +2,7 @@ use std::{io, result}; use thiserror::Error; -use crate::{codegen, interpreter, parser}; +use crate::{codegen, interpreter, parser, tc}; #[derive(Error, Debug)] pub enum Error { @@ -18,6 +18,9 @@ pub enum Error { #[error("Compile error: {0}")] CodegenError(#[from] codegen::Error), + #[error("Type error: {0}")] + TypeError(#[from] tc::Error), + #[error("{0}")] Message(String), } @@ -28,6 +31,12 @@ impl From<String> for Error { } } +impl<'a> From<&'a str> for Error { + fn from(s: &'a str) -> Self { + Self::Message(s.to_owned()) + } +} + impl<'a> From<nom::Err<nom::error::Error<&'a str>>> for Error { fn from(e: nom::Err<nom::error::Error<&'a str>>) -> Self { use nom::error::Error as NomError; |