mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
impl Error for Exceptions
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::fmt;
|
use std::{error::Error, fmt};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Exceptions {
|
pub enum Exceptions {
|
||||||
@@ -15,5 +15,34 @@ pub enum Exceptions {
|
|||||||
IndexOutOfBoundsException(String),
|
IndexOutOfBoundsException(String),
|
||||||
RuntimeException(String),
|
RuntimeException(String),
|
||||||
ParseException(String),
|
ParseException(String),
|
||||||
ReaderDecodeException()
|
ReaderDecodeException(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Exceptions {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Exceptions::IllegalArgumentException(a) => {
|
||||||
|
write!(f, "IllegalArgumentException - {}", a)
|
||||||
|
}
|
||||||
|
Exceptions::UnsupportedOperationException(a) => {
|
||||||
|
write!(f, "UnsupportedOperationException - {}", a)
|
||||||
|
}
|
||||||
|
Exceptions::IllegalStateException(a) => write!(f, "IllegalStateException - {}", a),
|
||||||
|
Exceptions::ArithmeticException(a) => write!(f, "ArithmeticException - {}", a),
|
||||||
|
Exceptions::NotFoundException(a) => write!(f, "NotFoundException - {}", a),
|
||||||
|
Exceptions::FormatException(a) => write!(f, "FormatException - {}", a),
|
||||||
|
Exceptions::ChecksumException(a) => write!(f, "ChecksumException - {}", a),
|
||||||
|
Exceptions::ReaderException(a) => write!(f, "ReaderException - {}", a),
|
||||||
|
Exceptions::WriterException(a) => write!(f, "WriterException - {}", a),
|
||||||
|
Exceptions::ReedSolomonException(a) => write!(f, "ReedSolomonException - {}", a),
|
||||||
|
Exceptions::IndexOutOfBoundsException(a) => {
|
||||||
|
write!(f, "IndexOutOfBoundsException - {}", a)
|
||||||
|
}
|
||||||
|
Exceptions::RuntimeException(a) => write!(f, "RuntimeException - {}", a),
|
||||||
|
Exceptions::ParseException(a) => write!(f, "ParseException - {}", a),
|
||||||
|
Exceptions::ReaderDecodeException() => write!(f, "ReaderDecodeException - -"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for Exceptions {}
|
||||||
|
|||||||
Reference in New Issue
Block a user