From f934e142ba3cada8929adfa6b3d4ca97ed776da4 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Wed, 21 May 2025 13:32:39 +0200 Subject: [PATCH] misc: rate_limiter: streamline #[source] and Error impl This streamlines the Error implementation in the Cloud Hypervisor code base to match the remaining parts so that everything follows the agreed conventions. These are leftovers missed in the previous commits. Signed-off-by: Philipp Schuster On-behalf-of: SAP philipp.schuster@sap.com --- rate_limiter/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rate_limiter/src/lib.rs b/rate_limiter/src/lib.rs index 9fc12ddd4..6f74d4c16 100644 --- a/rate_limiter/src/lib.rs +++ b/rate_limiter/src/lib.rs @@ -52,18 +52,21 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Mutex; use std::time::{Duration, Instant}; +use thiserror::Error; use vmm_sys_util::timerfd::TimerFd; /// Module for group rate limiting. pub mod group; -#[derive(Debug)] +#[derive(Error, Debug)] /// Describes the errors that may occur while handling rate limiter events. pub enum Error { /// The event handler was called spuriously. + #[error("Event handler was called spuriously: {0}")] SpuriousRateLimiterEvent(&'static str), /// The event handler encounters while TimerFd::wait() - TimerFdWaitError(std::io::Error), + #[error("Failed to wait for the timer: {0}")] + TimerFdWaitError(#[source] std::io::Error), } // Interval at which the refill timer will run when limiter is at capacity.