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

Function GetCode

pkg/errors/errors.go:498–503  ·  view source on GitHub ↗

GetCode returns the error code from an error, or empty string if not a structured error. Extracts the ErrorCode from a *Error. Returns empty string for non-Error types. Parameters: - err: The error to extract code from Returns the ErrorCode if err is a *Error, empty string otherwise. Example:

(err error)

Source from the content-addressed store, hash-verified

496// log.Printf("SQL error [%s]: %v", code, err)
497// }
498func GetCode(err error) ErrorCode {
499 if e, ok := err.(*Error); ok {
500 return e.Code
501 }
502 return ""
503}

Callers 3

Example_errorCodesFunction · 0.92
TestGetCodeFunction · 0.85

Calls

no outgoing calls

Tested by 3

Example_errorCodesFunction · 0.74
TestGetCodeFunction · 0.68