frost_bluepallas/
errors.rs1use alloc::{boxed::Box, string::String};
4use core::{error, fmt, result::Result};
5
6pub type BluePallasResult<T> = Result<T, Box<dyn error::Error>>;
8
9#[derive(Debug, Clone, PartialEq, Eq)]
11pub enum BluePallasError {
12 SerializationError(String),
14
15 DeSerializationError(String),
17
18 NoMessageProvided,
20
21 SaveSignatureError(String),
23
24 InvalidMemo(String),
26}
27
28impl fmt::Display for BluePallasError {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 BluePallasError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
32 BluePallasError::DeSerializationError(msg) => {
33 write!(f, "Deserialization error: {}", msg)
34 }
35 BluePallasError::NoMessageProvided => {
36 write!(f, "No messages have been provided for signing")
37 }
38 BluePallasError::SaveSignatureError(msg) => {
39 write!(f, "Failed to save signature: {}", msg)
40 }
41 BluePallasError::InvalidMemo(msg) => write!(f, "Invalid memo: {}", msg),
42 }
43 }
44}
45
46impl error::Error for BluePallasError {}
47
48impl BluePallasError {
50 pub fn serialization_error(message: impl Into<String>) -> Self {
52 BluePallasError::SerializationError(message.into())
53 }
54
55 pub fn deserialization_error(message: impl Into<String>) -> Self {
57 BluePallasError::DeSerializationError(message.into())
58 }
59
60 pub fn invalid_memo(message: impl Into<String>) -> Self {
62 BluePallasError::InvalidMemo(message.into())
63 }
64}