Skip to content

Commit 1b44b21

Browse files
committed
feat: Remove size boundary for capture_fail
1 parent b408b9e commit 1b44b21

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/integrations/failure.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ 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: &F) -> Event<'static>
139-
where
140-
F: Fail + Sized,
141-
{
138+
pub fn event_from_fail<F: Fail>(fail: &F) -> Event<'static> {
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) {
142+
exceptions.push(single_fail_to_exception(cause, cause.backtrace()));
143+
node = cause;
144+
}
145+
142146
Event {
143-
exceptions: failure::Fail::causes(fail)
144-
.map(|cause| single_fail_to_exception(cause, cause.backtrace()))
145-
.collect(),
147+
exceptions: exceptions,
146148
level: Level::Error,
147149
..Default::default()
148150
}
@@ -154,10 +156,7 @@ pub fn capture_error(err: &Error) -> Uuid {
154156
}
155157

156158
/// Captures a `failure::Fail`.
157-
pub fn capture_fail<F>(fail: &F) -> Uuid
158-
where
159-
F: Fail + Sized,
160-
{
159+
pub fn capture_fail<F: Fail>(fail: &F) -> Uuid {
161160
with_client_and_scope(|client, scope| client.capture_event(event_from_fail(fail), Some(scope)))
162161
}
163162

@@ -207,10 +206,7 @@ pub fn tap_error<T>(rv: Result<T, Error>) -> Result<T, Error> {
207206
/// # Ok(()) }
208207
/// # fn main() { test().unwrap() }
209208
/// ```
210-
pub fn tap_fail<T, F>(rv: Result<T, F>) -> Result<T, F>
211-
where
212-
F: Fail + Sized,
213-
{
209+
pub fn tap_fail<T, F: Fail>(rv: Result<T, F>) -> Result<T, F> {
214210
match rv {
215211
Ok(value) => Ok(value),
216212
Err(error) => {

0 commit comments

Comments
 (0)