diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2024-10-24 10:45:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-24 10:45:17 -0700 |
commit | c71e020668b40666aecfdffb1dbf979abcb41958 (patch) | |
tree | 6b963905f50c17c21d9a89a5f5f7eee2fa83e808 /ext/node/ops/zlib/mode.rs | |
parent | b063cfecfe0479b1de14b8e9e06f1921ce830127 (diff) |
refactor(ext/node): use concrete error types (#26419)
Diffstat (limited to 'ext/node/ops/zlib/mode.rs')
-rw-r--r-- | ext/node/ops/zlib/mode.rs | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/ext/node/ops/zlib/mode.rs b/ext/node/ops/zlib/mode.rs index 753300cc4..41565f9b1 100644 --- a/ext/node/ops/zlib/mode.rs +++ b/ext/node/ops/zlib/mode.rs @@ -1,19 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -#[derive(Debug)] -pub enum Error { - BadArgument, -} - -impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Error::BadArgument => write!(f, "bad argument"), - } - } -} - -impl std::error::Error for Error {} +#[derive(Debug, thiserror::Error)] +#[error("bad argument")] +pub struct ModeError; macro_rules! repr_i32 { ($(#[$meta:meta])* $vis:vis enum $name:ident { @@ -25,12 +14,12 @@ macro_rules! repr_i32 { } impl core::convert::TryFrom<i32> for $name { - type Error = Error; + type Error = ModeError; fn try_from(v: i32) -> Result<Self, Self::Error> { match v { $(x if x == $name::$vname as i32 => Ok($name::$vname),)* - _ => Err(Error::BadArgument), + _ => Err(ModeError), } } } |