From 50d47cdfc3f1f3571357d8d40519919e0c0d982e Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 31 May 2023 14:25:29 +0200 Subject: [PATCH] Implement `std::error::Error` for new metadata `Error` type Since the introduction of [a new `Error` type in the metadata] it is impossible to bubble up results from `File::new()` into `anyhow` using the `?` operator because this type doesn't implement `Error`, while it can be trivially implemented with all functions left at their default implementation. [a new `Error` type in the metadata]: https://github.com/microsoft/windows-rs/pull/2510/files#r1203845316 --- crates/libs/metadata/src/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/libs/metadata/src/error.rs b/crates/libs/metadata/src/error.rs index 31926e938b..66f9143d62 100644 --- a/crates/libs/metadata/src/error.rs +++ b/crates/libs/metadata/src/error.rs @@ -7,6 +7,8 @@ pub struct Error { span: Option<(usize, usize)>, } +impl std::error::Error for Error {} + impl From for std::io::Error { fn from(error: Error) -> Self { std::io::Error::new(std::io::ErrorKind::Other, error.message.as_str())