Created
February 6, 2020 02:08
-
-
Save mdwhatcott/de0391b63408830198e009522f7071cb to your computer and use it in GitHub Desktop.
Go Stack Trace Error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StackTraceError struct { | |
inner error | |
stack []byte | |
} | |
func NewStackTraceError(inner error) *StackTraceError { | |
return &StackTraceError{ | |
inner: inner, | |
stack: debug.Stack(), | |
} | |
} | |
func (this *StackTraceError) Error() string { | |
return fmt.Sprintf("error: %q\nstack:\n%s", this.inner, this.stack) | |
} | |
func (this *StackTraceError) Unwrap() error { | |
return this.inner | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment