From 3928d3a818f4d73e2a2806c8751f46073ab57b9c Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Fri, 13 Jan 2023 01:00:31 +0200 Subject: [PATCH] Implement std::error::Error for GDError --- src/errors.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/errors.rs b/src/errors.rs index ca360cf..afefef1 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,10 +1,12 @@ //! The library's possible errors. +use std::fmt; +use std::{fmt::Formatter, error::Error}; /// Result of Type and GDError. pub type GDResult = Result; -/// GameDigError. +/// GameDig Error. #[derive(Debug, Clone)] pub enum GDError { /// The received packet was bigger than the buffer size. @@ -38,3 +40,11 @@ pub enum GDError { /// Couldn't parse a value. TypeParse, } + +impl Error for GDError {} + +impl fmt::Display for GDError { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self) + } +}