Skip to content

Commit 921cb1a

Browse files
committed
feat: Add invalid pointer error variant and rename NulPointer to Null
1 parent 3527a60 commit 921cb1a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/error.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ use std::str::Utf8Error;
99
#[derive(Debug)]
1010
pub enum PointerError {
1111
#[allow(missing_docs)] // Obviously, the name is the ref doc.
12-
NulPointer,
12+
Null,
13+
/// A pointer that was not previously lent to the FFI user.
14+
Invalid,
1315
/// Trying to convert to `&str` a C string which content is not valid UTF-8.
1416
Utf8Error(Utf8Error),
1517
}
1618

1719
impl std::fmt::Display for PointerError {
1820
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1921
match *self {
20-
Self::NulPointer => {
22+
Self::Null => {
2123
write!(f, "dereference a null pointer will produce a crash")
2224
}
25+
Self::Invalid => {
26+
write!(f, "dereference a unknown pointer could produce a crash")
27+
}
2328
Self::Utf8Error(..) => {
2429
write!(f, "the provided C string is not a valid UTF-8 string")
2530
}
@@ -30,7 +35,8 @@ impl std::fmt::Display for PointerError {
3035
impl std::error::Error for PointerError {
3136
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
3237
match *self {
33-
Self::NulPointer => None,
38+
Self::Null => None,
39+
Self::Invalid => None,
3440
Self::Utf8Error(ref e) => Some(e),
3541
}
3642
}

0 commit comments

Comments
 (0)