MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / ExtractErrorCode

Function ExtractErrorCode

pkg/errors/formatter.go:355–360  ·  view source on GitHub ↗

ExtractErrorCode extracts the ErrorCode from a GoSQLX *Error. Unlike GetCode, this function returns a boolean indicating whether the extraction succeeded, making it suitable for use in type-switch–style handling. Returns the ErrorCode and true when err is a *Error; returns an empty string and false

(err error)

Source from the content-addressed store, hash-verified

353// Returns the ErrorCode and true when err is a *Error; returns an empty string
354// and false for all other error types.
355func ExtractErrorCode(err error) (ErrorCode, bool) {
356 if structErr, ok := err.(*Error); ok {
357 return structErr.Code, true
358 }
359 return "", false
360}

Callers 1

TestExtractErrorCodeFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExtractErrorCodeFunction · 0.68