Improve error generation for USDPL
This commit is contained in:
parent
554cb937a9
commit
d07cba6a38
1 changed files with 24 additions and 0 deletions
|
@ -54,6 +54,30 @@ pub enum ServiceError {
|
|||
}
|
||||
}
|
||||
|
||||
impl ServiceError {
|
||||
pub fn variant_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Encode(_) => "encode",
|
||||
Self::Decode(_) => "decode",
|
||||
Self::MethodNotFound => "method not found",
|
||||
Self::ServiceNotFound => "service not found",
|
||||
Self::Method(_) => "method",
|
||||
Self::StreamLength { .. } => "stream length",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn variant(&self) -> u64 {
|
||||
match self {
|
||||
Self::Encode(_) => 0b10,
|
||||
Self::Decode(_) => 0b11,
|
||||
Self::MethodNotFound => 0b100,
|
||||
Self::ServiceNotFound => 0b101,
|
||||
Self::Method(_) => 0b1000,
|
||||
Self::StreamLength { .. } => 0b10000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ServiceError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
|
|
Loading…
Add table
Reference in a new issue