@@ -105,7 +105,7 @@ fn parse_stacktrace(bt: &str) -> Option<Stacktrace> {
105
105
Stacktrace :: from_frames_reversed ( frames)
106
106
}
107
107
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 {
109
109
Exception {
110
110
ty : error_typename ( f) ,
111
111
value : Some ( f. to_string ( ) ) ,
@@ -135,12 +135,13 @@ pub fn event_from_error(err: &failure::Error) -> Event<'static> {
135
135
}
136
136
137
137
/// 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 > {
139
139
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 ( ) ) {
142
143
exceptions. push ( single_fail_to_exception ( cause, cause. backtrace ( ) ) ) ;
143
- node = cause;
144
+ ptr = Some ( cause) ;
144
145
}
145
146
146
147
Event {
@@ -156,7 +157,7 @@ pub fn capture_error(err: &Error) -> Uuid {
156
157
}
157
158
158
159
/// 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 {
160
161
with_client_and_scope ( |client, scope| client. capture_event ( event_from_fail ( fail) , Some ( scope) ) )
161
162
}
162
163
0 commit comments