@@ -105,7 +105,7 @@ fn parse_stacktrace(bt: &str) -> Option<Stacktrace> {
105105 Stacktrace :: from_frames_reversed ( frames)
106106}
107107
108- fn single_fail_to_exception ( f : & Fail , bt : Option < & failure:: Backtrace > ) -> Exception {
108+ fn single_fail_to_exception < F : Fail + ? Sized > ( f : & F , bt : Option < & failure:: Backtrace > ) -> Exception {
109109 Exception {
110110 ty : error_typename ( f) ,
111111 value : Some ( f. to_string ( ) ) ,
@@ -135,12 +135,13 @@ pub fn event_from_error(err: &failure::Error) -> Event<'static> {
135135}
136136
137137/// Helper function to create an event from a `failure::Fail`.
138- pub fn event_from_fail < F : Fail > ( fail : & F ) -> Event < ' static > {
138+ pub fn event_from_fail < F : Fail + ? Sized > ( fail : & F ) -> Event < ' static > {
139139 let mut exceptions = vec ! [ single_fail_to_exception( fail, fail. backtrace( ) ) ] ;
140- let mut node = fail as & Fail ;
141- while let Some ( cause) = Fail :: cause ( node) {
140+
141+ let mut ptr: Option < & Fail > = None ;
142+ while let Some ( cause) = ptr. map ( Fail :: cause) . unwrap_or_else ( || fail. cause ( ) ) {
142143 exceptions. push ( single_fail_to_exception ( cause, cause. backtrace ( ) ) ) ;
143- node = cause;
144+ ptr = Some ( cause) ;
144145 }
145146
146147 Event {
@@ -156,7 +157,7 @@ pub fn capture_error(err: &Error) -> Uuid {
156157}
157158
158159/// Captures a `failure::Fail`.
159- pub fn capture_fail < F : Fail > ( fail : & F ) -> Uuid {
160+ pub fn capture_fail < F : Fail + ? Sized > ( fail : & F ) -> Uuid {
160161 with_client_and_scope ( |client, scope| client. capture_event ( event_from_fail ( fail) , Some ( scope) ) )
161162}
162163
0 commit comments