Implement Error and Display traits for Error enum.

Also implement From<Error> for i32.

Change-Id: I6d63a4d61013c014d58ada6c396d0e8108f9bbc1
Signed-off-by: Andrew Walbran <qwandor@google.com>
diff --git a/Cargo.lock b/Cargo.lock
index 60e2f03..6a7ca7b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -7,6 +7,7 @@
 version = "0.1.0"
 dependencies = [
  "num_enum",
+ "thiserror",
  "uuid",
 ]
 
@@ -50,9 +51,9 @@
 
 [[package]]
 name = "syn"
-version = "2.0.85"
+version = "2.0.87"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56"
+checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -60,6 +61,26 @@
 ]
 
 [[package]]
+name = "thiserror"
+version = "2.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
 name = "unicode-ident"
 version = "1.0.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 90ed22a..cecea86 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,4 +16,5 @@
 
 [dependencies]
 num_enum = { version = "0.7", default-features = false }
+thiserror = { version = "2.0.3", default-features = false }
 uuid = { version = "1.10", default-features = false }
diff --git a/src/lib.rs b/src/lib.rs
index ca1190e..18dfd19 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,8 @@
 extern crate alloc;
 
 use alloc::string::String;
-use num_enum::TryFromPrimitive;
+use num_enum::{IntoPrimitive, TryFromPrimitive};
+use thiserror::Error;
 use uuid::Uuid;
 
 pub mod boot_info;
@@ -22,17 +23,26 @@
 }
 
 /// FF-A v1.1, Table 12.2: Error status codes
-#[derive(Debug, Eq, PartialEq, Clone, Copy, TryFromPrimitive)]
+#[derive(Clone, Copy, Debug, Eq, Error, IntoPrimitive, PartialEq, TryFromPrimitive)]
 #[repr(i32)]
 pub enum Error {
+    #[error("Not supported")]
     NotSupported = -1,
+    #[error("Invalid parameters")]
     InvalidParameters = -2,
+    #[error("No memory")]
     NoMemory = -3,
+    #[error("Busy")]
     Busy = -4,
+    #[error("Interrupted")]
     Interrupted = -5,
+    #[error("Denied")]
     Denied = -6,
+    #[error("Retry")]
     Retry = -7,
+    #[error("Aborted")]
     Aborted = -8,
+    #[error("No data")]
     NoData = -9,
 }