refactor(ops/posix_mq.rs): Update code using deprecated Error trait
The previous Error::description method was deprecated. Change-Id: I63efd272484c8715b9f324ab09e967fbf53cf55a Reviewed-on: https://cl.tvl.fyi/c/depot/+/5224 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
487dd4189e
commit
054fe8f94b
1 changed files with 21 additions and 18 deletions
|
@ -17,7 +17,7 @@ use std::num;
|
||||||
/// * ENAMETOOLONG: This crate performs name validation
|
/// * ENAMETOOLONG: This crate performs name validation
|
||||||
///
|
///
|
||||||
/// If an unexpected error is encountered it will be wrapped appropriately and should be reported
|
/// If an unexpected error is encountered it will be wrapped appropriately and should be reported
|
||||||
/// as a bug on https://github.com/aprilabank/posix_mq.rs
|
/// as a bug on https://b.tvl.fyi
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
@ -50,10 +50,10 @@ pub enum Error {
|
||||||
UnknownInternalError(Option<nix::Error>),
|
UnknownInternalError(Option<nix::Error>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for Error {
|
impl fmt::Display for Error {
|
||||||
fn description(&self) -> &str {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
match *self {
|
f.write_str(match *self {
|
||||||
// This error contains more sensible description strings already
|
// This error contains more sensible description strings already
|
||||||
InvalidQueueName(e) => e,
|
InvalidQueueName(e) => e,
|
||||||
ValueReadingError(_) => "error reading system configuration for message queues",
|
ValueReadingError(_) => "error reading system configuration for message queues",
|
||||||
|
@ -67,21 +67,25 @@ impl error::Error for Error {
|
||||||
QueueNotFound() => "the specified queue could not be found",
|
QueueNotFound() => "the specified queue could not be found",
|
||||||
InsufficientMemory() => "insufficient memory to call queue method",
|
InsufficientMemory() => "insufficient memory to call queue method",
|
||||||
InsufficientSpace() => "insufficient space to call queue method",
|
InsufficientSpace() => "insufficient space to call queue method",
|
||||||
ProcessFileDescriptorLimitReached() =>
|
ProcessFileDescriptorLimitReached() => {
|
||||||
"maximum number of process file descriptors reached",
|
"maximum number of process file descriptors reached"
|
||||||
SystemFileDescriptorLimitReached() =>
|
}
|
||||||
"maximum number of system file descriptors reached",
|
SystemFileDescriptorLimitReached() => {
|
||||||
|
"maximum number of system file descriptors reached"
|
||||||
|
}
|
||||||
UnknownForeignError(_) => "unknown foreign error occured: please report a bug!",
|
UnknownForeignError(_) => "unknown foreign error occured: please report a bug!",
|
||||||
UnknownInternalError(_) => "unknown internal error occured: please report a bug!",
|
UnknownInternalError(_) => "unknown internal error occured: please report a bug!",
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl error::Error for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||||
// Explicitly import this to gain access to Error::description()
|
match self {
|
||||||
use std::error::Error;
|
Error::ValueReadingError(e) => Some(e),
|
||||||
f.write_str(self.description())
|
Error::UnknownForeignError(e) => Some(e),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +115,6 @@ impl From<num::ParseIntError> for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn match_errno(err: nix::errno::Errno) -> Error {
|
fn match_errno(err: nix::errno::Errno) -> Error {
|
||||||
use nix::errno::Errno::*;
|
use nix::errno::Errno::*;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue