1use aura_core::AuraError;
7
8#[derive(Debug, thiserror::Error)]
10pub enum Layer3Error {
11 #[error("Unsupported operation: {operation}")]
13 UnsupportedOperation {
14 operation: &'static str,
16 },
17
18 #[error("Handler failure: {message}")]
20 HandlerFailure {
21 message: String,
23 },
24
25 #[error("Invalid input: {message}")]
27 InvalidInput {
28 message: String,
30 },
31}
32
33impl Layer3Error {
34 pub fn unsupported(operation: &'static str) -> Self {
36 Self::UnsupportedOperation { operation }
37 }
38
39 pub fn handler_failure(message: impl Into<String>) -> Self {
41 Self::HandlerFailure {
42 message: message.into(),
43 }
44 }
45
46 pub fn invalid_input(message: impl Into<String>) -> Self {
48 Self::InvalidInput {
49 message: message.into(),
50 }
51 }
52}
53
54impl From<Layer3Error> for AuraError {
55 fn from(error: Layer3Error) -> Self {
56 match error {
57 Layer3Error::UnsupportedOperation { operation } => {
58 AuraError::invalid(format!("Unsupported operation: {operation}"))
59 }
60 Layer3Error::HandlerFailure { message } => AuraError::internal(message),
61 Layer3Error::InvalidInput { message } => AuraError::invalid(message),
62 }
63 }
64}