From 141c8d8f4fab47f28a00010c18dff135bc2fb56e Mon Sep 17 00:00:00 2001 From: Christian Beilschmidt Date: Mon, 31 Oct 2022 11:55:40 +0100 Subject: [PATCH] stop reading error messages if they were not set --- src/driver.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 5dae5425..b8087b84 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -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 { + method_name: "GDALGetDriver", + msg: "Unable to find driver".to_string(), + }); } Ok(Driver { c_driver }) } @@ -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 }) }