From d898696d6cc8d2ed2372e23111b577972f68fa38 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 13 Oct 2023 20:16:14 -0400 Subject: [PATCH] Add error messages --- src/error.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/error.rs b/src/error.rs index 6f3750e..f699253 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,7 +5,7 @@ use crate::{value::Value, Identifier}; -use std::{fmt, io, time::SystemTimeError}; +use std::{fmt, io, time}; pub type Result = std::result::Result; @@ -18,10 +18,6 @@ pub enum Error { relevant_source: String, }, - ExpectedChildNode { - empty_node_sexp: String, - }, - /// The 'assert' macro did not resolve successfully. AssertEqualFailed { expected: Value, @@ -162,8 +158,8 @@ impl From for Error { } } -impl From for Error { - fn from(value: SystemTimeError) -> Self { +impl From for Error { + fn from(value: time::SystemTimeError) -> Self { Error::ToolFailure(value.to_string()) } } @@ -281,10 +277,9 @@ impl fmt::Display for Error { f, "Expected syntax node {expected}, but got {actual} at {location}. Code: {relevant_source} ", ), - ExpectedChildNode { empty_node_sexp } => todo!(), - WrongColumnAmount { expected, actual } => todo!(), - ToolFailure(_) => todo!(), - CustomMessage(_) => todo!(), + WrongColumnAmount { expected, actual } => write!(f, "Wrong column amount. Expected {expected} but got {actual}."), + ToolFailure(message) => write!(f, "{message}"), + CustomMessage(message) => write!(f, "{message}"), } } }