Skip to content

Commit 7d93104

Browse files
committed
Print error codes in hex; include codes in documentation
1 parent 23d8285 commit 7d93104

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/error.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ const CODE_UNAVAILABLE: u32 = CODE_PREFIX | 1;
1919

2020
/// An unknown error.
2121
pub const UNKNOWN: Error = Error(unsafe {
22+
///
23+
/// This is the following constant: 57F40000 (hex) / 1475608576 (decimal).
2224
NonZeroU32::new_unchecked(CODE_UNKNOWN)
2325
});
2426

2527
/// No generator is available.
2628
pub const UNAVAILABLE: Error = Error(unsafe {
29+
///
30+
/// This is the following constant: 57F40001 (hex) / 1475608577 (decimal).
2731
NonZeroU32::new_unchecked(CODE_UNAVAILABLE)
2832
});
2933

@@ -61,7 +65,7 @@ impl fmt::Debug for Error {
6165
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
6266
match self.msg() {
6367
Some(msg) => write!(f, "Error(\"{}\")", msg),
64-
None => write!(f, "Error({})", self.0.get()),
68+
None => write!(f, "Error({:08X})", self.0),
6569
}
6670
}
6771
}
@@ -70,7 +74,7 @@ impl fmt::Display for Error {
7074
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
7175
match self.msg() {
7276
Some(msg) => write!(f, "{}", msg),
73-
None => write!(f, "getrandom: unknown code {}", self.0.get()),
77+
None => write!(f, "getrandom: unknown code {:08X}", self.0),
7478
}
7579
}
7680
}

0 commit comments

Comments
 (0)