1use std::fmt::Debug;
2
3use rusty_mms_service::error::MmsServiceError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum IccpError {
8 #[error("ICCP Protocol Error - {}", .0)]
9 ProtocolError(String),
10
11 #[error("ICCP Protocol Stack Error - {}", .0)]
12 ProtocolStackError(#[from] MmsServiceError),
13
14 #[error("ICCP IO Error: {:?}", .0)]
15 IoError(#[from] std::io::Error),
16
17 #[error("ICCP Error: {}", .0)]
18 InternalError(String),
19}
20
21pub(crate) fn to_iccp_error<T: Debug>(message: &str) -> impl FnOnce(T) -> IccpError {
22 move |error| IccpError::ProtocolError(format!("{}: {:?}", message, error))
23}