Skip to content

Commit

Permalink
Handling self.error_string() failing in Debug for DriverError (#267)
Browse files Browse the repository at this point in the history
* Handling self.error_string() failing in Debug for DriverError

* Fixing clippy
  • Loading branch information
coreylowman authored Jul 1, 2024
1 parent 32538f2 commit 95fff6d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/driver/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ impl DriverError {

impl std::fmt::Debug for DriverError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let err_str = self.error_string().unwrap();
f.debug_tuple("DriverError")
.field(&self.0)
.field(&err_str)
.finish()
match self.error_string() {
Ok(err_str) => f
.debug_tuple("DriverError")
.field(&self.0)
.field(&err_str)
.finish(),
Err(_) => f
.debug_tuple("DriverError")
.field(&self.0)
.field(&"<Failure when calling cuGetErrorString()>")
.finish(),
}
}
}

Expand Down

0 comments on commit 95fff6d

Please sign in to comment.