From 26717f6f3bf35cf85195a4e10c058b2fefd7016f Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 12 Mar 2023 13:39:21 +0100 Subject: [PATCH 1/2] error: enable core::error::Error for all error payloads --- CHANGELOG.md | 3 +++ uefi/src/result/error.rs | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6976186c..6ebd13efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,9 @@ `HandleBuffer::handles` and `ProtocolsPerHandle::protocols` methods have been deprecated. - Removed `'boot` lifetime from the `Output` protocol. +- The generic type `Data` of `uefi::Error` doesn't need to be + `Display` to be compatible with `core::error::Error`. Note that the error + Trait requires the `unstable` feature. ## uefi-macros - [Unreleased] diff --git a/uefi/src/result/error.rs b/uefi/src/result/error.rs index 26634c1f6..094d5be82 100644 --- a/uefi/src/result/error.rs +++ b/uefi/src/result/error.rs @@ -1,7 +1,7 @@ use super::Status; use core::fmt::{Debug, Display}; -/// Errors emitted from UEFI entry point must propagate erronerous UEFI statuses, +/// Errors emitted from UEFI entry point must propagate erroneous UEFI statuses, /// and may optionally propagate additional entry point-specific data. #[derive(Debug, PartialEq, Eq)] pub struct Error { @@ -40,11 +40,11 @@ impl From for Error<()> { } } -impl Display for Error { +impl Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "UEFI Error {}: {}", self.status(), self.data()) + write!(f, "UEFI Error {}: {:?}", self.status(), self.data()) } } #[cfg(feature = "unstable")] -impl core::error::Error for Error {} +impl core::error::Error for Error {} From d647d465bfa261d2029e6be37a17c3da8e95f3d5 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Sun, 12 Mar 2023 15:46:34 +0100 Subject: [PATCH 2/2] improve uefi::Error documentation --- uefi/src/result/error.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/uefi/src/result/error.rs b/uefi/src/result/error.rs index 094d5be82..835676b5a 100644 --- a/uefi/src/result/error.rs +++ b/uefi/src/result/error.rs @@ -1,8 +1,11 @@ +//! Module for UEFI-specific error encodings. See [`Error`]. + use super::Status; use core::fmt::{Debug, Display}; -/// Errors emitted from UEFI entry point must propagate erroneous UEFI statuses, -/// and may optionally propagate additional entry point-specific data. +/// An UEFI-related error with optionally additional payload data. The error +/// kind is encoded in the `status` field (see [`Status`]). Additional payload +/// may be inside the `data` field. #[derive(Debug, PartialEq, Eq)] pub struct Error { status: Status,