Skip to content

Commit

Permalink
stop reading error messages if they were not set
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed Oct 31, 2022
1 parent 49fdfd4 commit 141c8d8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ impl DriverManager {
_register_drivers();
let c_driver = unsafe { gdal_sys::GDALGetDriver(index.try_into().unwrap()) };
if c_driver.is_null() {
return Err(_last_null_pointer_err("GDALGetDriver"));
// `GDALGetDriver` just returns `null` and sets no error message
return Err(GdalError::NullPointer {

This comment has been minimized.

Copy link
@lnicola

lnicola Oct 31, 2022

Member

Just for completeness, we could also return Option<Driver> here, I don't have any preference.

method_name: "GDALGetDriver",
msg: "Unable to find driver".to_string(),
});
}
Ok(Driver { c_driver })
}
Expand All @@ -427,7 +431,11 @@ impl DriverManager {
let c_name = CString::new(name)?;
let c_driver = unsafe { gdal_sys::GDALGetDriverByName(c_name.as_ptr()) };
if c_driver.is_null() {
return Err(_last_null_pointer_err("GDALGetDriverByName"));
// `GDALGetDriverByName` just returns `null` and sets no error message
return Err(GdalError::NullPointer {
method_name: "GDALGetDriverByName",
msg: "Unable to find driver".to_string(),
});
};
Ok(Driver { c_driver })
}
Expand Down

0 comments on commit 141c8d8

Please sign in to comment.