From 29e713c6efe55602922e0a7986b950afbd0a5500 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 29 Oct 2018 21:46:03 +0100 Subject: Move error handling to failure --- src/error.rs | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index a936736..2ed9bd5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -4,24 +4,26 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // -//! Error module, containing error types -error_chain!{ - errors { - /// Error kind indicating that the JSON parser failed - ParserError { - description("Failed to create a Task from JSON") - } - /// Error kind indicating that the Reader failed to read something - ReaderError { - description("Failed to read tasks from a Reader") - } - /// Error kind indicating that a call to the task warrior binary failed - TaskCmdError { - description("There was a problem while calling the external 'task' binary") - } - /// Error kind indicating that a conversion to JSON failed - SerializeError { - description("A Task could not be converted to JSON") - } - } +//! Definitions for error handling with failure + +/// Failure error kind type, defining error messages +#[derive(Debug, Clone, Eq, PartialEq, Fail)] +pub enum ErrorKind { + + /// Error kind indicating that the JSON parser failed + #[fail(display = "Failed to create a Task from JSON")] + ParserError, + + /// Error kind indicating that the Reader failed to read something + #[fail(display = "Failed to read tasks from a Reader")] + ReaderError, + + /// Error kind indicating that a call to the task warrior binary failed + #[fail(display = "There was a problem while calling the external 'task' binary")] + TaskCmdError, + + /// Error kind indicating that a conversion to JSON failed + #[fail(display = "A Task could not be converted to JSON")] + SerializeError } + -- cgit v1.2.3