Skip to content

Commit a3d521e

Browse files
authored
chore: add error message helper (#2247)
1 parent dc12684 commit a3d521e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/signer/src/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use alloy_primitives::{hex, ChainId};
22
use k256::ecdsa;
3-
use std::fmt;
3+
use std::{fmt, fmt::Display};
44
use thiserror::Error;
55

66
/// Result type alias for [`Error`](enum@Error).
@@ -47,6 +47,12 @@ impl Error {
4747
Self::Other(error.into())
4848
}
4949

50+
/// Constructs a new [`Other`](Self::Other) with an error message.
51+
#[cold]
52+
pub fn message(err: impl Display) -> Self {
53+
Self::Other(err.to_string().into())
54+
}
55+
5056
/// Returns `true` if the error is [`UnsupportedOperation`](Self::UnsupportedOperation).
5157
#[inline]
5258
pub const fn is_unsupported(&self) -> bool {

0 commit comments

Comments
 (0)