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

feat!(rm-cause): causes are harmful #620

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions pkg/events/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package events
import (
"fmt"
"io"
"os"
"strings"
"sync"

Expand Down Expand Up @@ -37,6 +38,7 @@ func (e *ErrorInfo) MarshalLog(addField func(key string, value interface{})) {
if len(e.Stack) > 0 {
addField("error.stack", strings.Join(e.Stack, "\n\t"))
}

if e.Cause != nil {
addField("error.cause", e.Cause)
}
Expand Down Expand Up @@ -144,15 +146,6 @@ func NewErrorInfo(err error) *ErrorInfo {
Stack: errStack(err),
Custom: custom,
}
// obtain nested error, collapsing upward if possible.
if cause := nestInfo(errors.Unwrap(err)); cause != nil {
if info.pureStack() && cause.pureMessage() {
info.Message = cause.Message
info.Cause = cause.Cause
} else {
info.Cause = cause
}
}
return &info
}

Expand All @@ -168,15 +161,6 @@ func nestInfo(err error) *nestedErrorInfo {
Stack: errStack(err),
Custom: custom,
}
// obtain nested error, collapsing upward if possible.
Copy link
Contributor

@asms asms Feb 1, 2025

Choose a reason for hiding this comment

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

Is this nestInfo function still needed? Maybe we can remove the whole function.

if cause := nestInfo(errors.Unwrap(err)); cause != nil {
if info.pureStack() && cause.pureMessage() {
info.Message = cause.Message
info.Cause = cause.Cause
} else {
info.Cause = cause
}
}
return &info
}

Expand Down
Loading