MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / errorFingerprint

Function errorFingerprint

main.go:151–172  ·  view source on GitHub ↗
(msg string, original error)

Source from the content-addressed store, hash-verified

149var statusCodeRe = regexp.MustCompile(`status (\d{3})`)
150
151func errorFingerprint(msg string, original error) string {
152 prefix := msg
153 if idx := strings.Index(msg, ": "); idx > 0 {
154 prefix = msg[:idx]
155 }
156
157 // Normalize to a slug.
158 fp := strings.ToLower(prefix)
159 fp = strings.ReplaceAll(fp, " ", "_")
160
161 // Append HTTP status code so different API errors are separate issues.
162 if m := statusCodeRe.FindStringSubmatch(msg); len(m) == 2 {
163 fp += "_" + m[1]
164 } else if original != nil {
165 var apiErr *api.APIError
166 if errors.As(original, &apiErr) {
167 fp += "_" + strconv.Itoa(apiErr.StatusCode)
168 }
169 }
170
171 return fp
172}

Callers 2

TestErrorFingerprintFunction · 0.85
initSentryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestErrorFingerprintFunction · 0.68