Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Execution Context to Errors #480

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

stsantilena
Copy link
Contributor

@stsantilena stsantilena commented Feb 10, 2023

This adds an error wrapper around our existing error type in the notify-stream library. It uses std::backtrace to capture the backtrace at the time of the error and returns it with the error:

Testing:

  • Have a unit test that covers the capture.
  • Windows compiler is throwing an E0658 error saying that backtrace is unstable. Although, looking through the rust git history, it looks it was actually stable now. I don't see this error in Linux or in the Jenkins pipeline.

Technical Notes:
Originally tried using the traceing_error crate but ran into issues. I couldn't get the SpanTrace::capture() function to work. Also, the in_current_span() method was not adding the SpanTrace to the Span as expected. That's why I pivoted to using std::backtrace instead. The downside is that It's a bit code heavy and may have performance implications if used too often.

JIRA Link: LOG-15034

@stsantilena stsantilena added the enhancement New feature or request label Feb 10, 2023
context: Backtrace::capture(),
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to create custom error type and constructor to pass the backtrace information along.

ErrorKind::PathNotFound => ContextError::new(Error::PathNotFound),
ErrorKind::WatchNotFound => ContextError::new(Error::WatchNotFound),
ErrorKind::InvalidConfig(c) => ContextError::new(Error::InvalidConfig(c)),
ErrorKind::MaxFilesWatch => ContextError::new(Error::MaxFilesWatch),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping our original Error type with the ContextError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant