Skip to content

Commit 8dc87b9

Browse files
committed
Handling self.error_string() failing in Debug for DriverError
1 parent 32538f2 commit 8dc87b9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/driver/result.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,18 @@ impl DriverError {
6060

6161
impl std::fmt::Debug for DriverError {
6262
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63-
let err_str = self.error_string().unwrap();
64-
f.debug_tuple("DriverError")
65-
.field(&self.0)
66-
.field(&err_str)
67-
.finish()
63+
match self.error_string() {
64+
Ok(err_str) => f
65+
.debug_tuple("DriverError")
66+
.field(&self.0)
67+
.field(err_str)
68+
.finish(),
69+
Err(_) => f
70+
.debug_tuple("DriverError")
71+
.field(&self.0)
72+
.field(&"<Failure when calling cuGetErrorString()>")
73+
.finish(),
74+
}
6875
}
6976
}
7077

0 commit comments

Comments
 (0)