feat: Initial
This commit is contained in:
commit
f0abca60db
26 files changed
+1112
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
IsStackCaptureEnabled = true
|
||||
StackCaptureSize = 1024 * 4
|
||||
)
|
||||
|
||||
type ErrorStack = []string
|
||||
|
||||
func CaptureStackIfEnabled() ErrorStack {
|
||||
if !IsStackCaptureEnabled {
|
||||
return nil
|
||||
}
|
||||
|
||||
return CaptureStack()
|
||||
}
|
||||
|
||||
func CaptureStack() ErrorStack {
|
||||
buffer := make([]byte, StackCaptureSize)
|
||||
stackSize := runtime.Stack(buffer, false)
|
||||
return strings.Split(string(buffer[:stackSize]), "\n")
|
||||
}
|
||||
Reference in new issue
Block a user