From b07d0e712f3467d417ce615617126aa5d18b7d06 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 3 May 2018 16:26:42 -0700 Subject: [PATCH] always provide backtrace for error --- src/error.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/error.rs b/src/error.rs index 963abd3b9..cc29fe638 100644 --- a/src/error.rs +++ b/src/error.rs @@ -48,11 +48,11 @@ impl Error { /// Returns a reference to the Backtrace carried by this error, if it /// carries one. - pub fn backtrace(&self) -> Option<&Backtrace> { + pub fn backtrace(&self) -> &Backtrace { if let Some(bt) = self.cause.backtrace() { - Some(bt) + bt } else { - self.backtrace.as_ref() + self.backtrace.as_ref().unwrap() } } } @@ -806,7 +806,7 @@ mod tests { #[test] fn test_backtrace() { let e = ErrorBadRequest("err"); - assert!(e.backtrace().is_some()); + let _ = e.backtrace(); } #[test]