Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Set get frames public #41

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

Open
ldreux wants to merge 1 commit into joomcode:master
base: master
Choose a base branch
Loading
from ldreux:master
Open

Set get frames public #41

ldreux wants to merge 1 commit into joomcode:master from ldreux:master

Conversation

@ldreux
Copy link

@ldreux ldreux commented Jan 21, 2023
edited
Loading

In our applications, we catch all errors in our webservices and our batches and create sentry issues with the errorx stacktrace.

errxFrames := errx.GetFrames()
framesLen := len(errxFrames)
sentryFrames := make([]sentry.Frame, framesLen)
for i, errxFrame := range errxFrames {
	sentryFrames[framesLen-i-1] = convertFrame(errxFrame)
}
func convertFrame(frame errorx.Frame) sentry.Frame {
	return sentry.Frame{
		Filename: frame.File(),
		Function: frame.Function(),
		Lineno: frame.Line(),
	}
}

Copy link
Collaborator

@PeterIvanov PeterIvanov left a comment

Choose a reason for hiding this comment

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

This PR requires a description.
The first thing to know here is a use case. I'm fairly sure that it's better to provide utilities for it, if it's a valid case, rather than exposing some internals from errorx.

Copy link
Collaborator

Maybe we adopt this exact use case?
Instead of API focused on just exposing stack frames, make an api for conversion. This would highlight that you don't need to extract this information as-is, but if you need to feed it to some system with custom stack frames format, you can.
Such conversion API can also be based on interface for errorx frame, not the actual representation, as an added bonus.
What's your view on such idea?

Copy link
Collaborator

@PeterIvanov PeterIvanov left a comment

Choose a reason for hiding this comment

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

Pending an answer to the question above, marking this PR as Request changes for now.

Copy link

For monitoring tools like github.com/getsentry/sentry-go, it's important to expose the callstack so the error can be traced.

https://github.com/getsentry/sentry-go/blob/824589bd5be49de6242d5f867a94c7df05510a4e/stacktrace.go#L74

This is how Sentry extracts stack trace from other error libraries. While I don't think errorx should necessarily adhere to the way Sentry parses stack trace, an exposed API to get the frames from the Error should be available for custom stack trace parsing.

Copy link

Instead of API focused on just exposing stack frames, make an api for conversion. This would highlight that you don't need to extract this information as-is, but if you need to feed it to some system with custom stack frames format, you can.

Im not sure how a conversion API for call stack works, can you provide an example?

Copy link
Collaborator

As far as I can recall, the idea was that we add an API like this:

func (e *Error) ExportStackFrames(originalFrames []FrameInterface) any

This way, we:

  1. Hint that extracting stack frames is not an intended high-level API for dealing with errors
  2. Hide behind the interface to avoid, say, marshalling issues

Copy link
Collaborator

In this PR, the second point is already addressed, so I'm generally OK with that. Just asked for an opinion on an idea.

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

Reviewers

@PeterIvanov PeterIvanov PeterIvanov requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /