feat: Initial

This commit is contained in:
Artёm Mishin committed 2025-04-25 11:20:31 +03:00
commit f0abca60db
26 files changed
+1112

No files matched your search

+27
View File
@@ -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")
}