Skip to content

log stacktrace on error fixes issue #84#97

Open
scottillogical wants to merge 2 commits intogocraft:masterfrom
scottillogical:master
Open

log stacktrace on error fixes issue #84#97
scottillogical wants to merge 2 commits intogocraft:masterfrom
scottillogical:master

Conversation

@scottillogical
Copy link
Copy Markdown

@scottillogical scottillogical commented May 8, 2018

right now, if a worker panics gotcraft work will just log (which is what i ran into) the error but not a stacktrace

ERROR: runJob.panic - runtime error: invalid memory address or nil pointer dereference

now it will also log a stacktrace as mentioned was desirable #84

@scottillogical
Copy link
Copy Markdown
Author

This still looks good and is very simple, can a maintainer look at it?

Comment thread log.go

func logError(key string, err error) {
fmt.Printf("ERROR: %s - %s\n", key, err.Error())
debug.PrintStack()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this is doing what you think it is. Isn't this just printing the stacktrace at the time of the call and will always print the same exact stack trace regardless of the error?

The canonical "Go way" of dealing with errors and stacktraces is: https://godoc.org/github.com/pkg/errors

Refactoring gocraft/work to use pkg/errors is a little more of an undertaking, but likely worth the effort.

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.

2 participants