Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Implement PropagateSkip and NewErrorSkip for Custom Frame Skipping - #1

Open
PandelisZ wants to merge 4 commits into
masterfrom
cosine/issue-15-fix-runtime-caller-frame-skip-y0p9jo
Open

PandelisZ wants to merge 4 commits into
masterfrom
cosine/issue-15-fix-runtime-caller-frame-skip-y0p9jo

Conversation

@PandelisZ

Copy link
Copy Markdown

This pull request introduces new functions to the stacktrace package: PropagateSkip, NewErrorSkip, and their variants. These functions allow users to skip an arbitrary number of frames in the stack trace, thereby enabling better stack trace reporting in helper functions. This solves the issue where the original invocation point of a helper function was replaced by the helper itself in the stack trace.

  • New Functions Introduced:

    • NewErrorSkip(skip int, msg string, vals ...interface{}) error: Creates a new error with the ability to skip specified stack frames.
    • PropagateSkip(cause error, skip int, msg string, vals ...interface{}) error: Propagates an error while allowing skip of frames.
    • NewErrorWithCodeSkip(code ErrorCode, skip int, msg string, vals ...interface{}) error: Similar to NewErrorWithCode, but allows skipping frames.
    • ErrorBuilder: Enhanced class to construct errors with custom skip values.
  • Testing: New tests in skip_test.go confirm that the correct caller information is maintained and that the helper function itself does not appear in the error string when using PropagateSkip and the builder methods.

These changes enhance usability for error handling within our libraries.


This pull request was co-created with Cosine Genie

Original Task: stacktrace/866fqf1v1hka
Author: Pandelis Zembashis

Comment thread stacktrace.go
If cause is nil, PropagateSkip returns nil.
*/
func PropagateSkip(cause error, skip int, msg string, vals ...interface{}) error {
if cause == nil {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Can we have some further logging of causes and effect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant