// Copyright (C) 2025-2099 The crate authors. // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU Affero General Public License as published by the // Free Software Foundation, either version 3 of the License, or (at your // option) any later version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License // for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . use std::error::Error as StdError; use std::io::Error as IoError; #[derive(Debug)] pub enum Error { UnknownHookType, Io(IoError), SerdeJson(serde_json::Error), } impl StdError for Error {} impl std::fmt::Display for Error { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Error::UnknownHookType => write!(fmt, "Unknown hook type"), Error::Io(e) => write!(fmt, "Io error: {}", e), Error::SerdeJson(e) => write!(fmt, "serde_json error: {}", e), } } } impl From for Error { fn from(err: IoError) -> Error { Error::Io(err) } } impl From for Error { fn from(err: serde_json::Error) -> Error { Error::SerdeJson(err) } }