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

Function IsCode

pkg/errors/errors.go:465–470  ·  view source on GitHub ↗

IsCode checks if an error has a specific error code. Type-safe way to check error codes for programmatic error handling. Works with both *Error and other error types (returns false for non-Error). Parameters: - err: The error to check - code: The ErrorCode to match against Returns true if err is

(err error, code ErrorCode)

Source from the content-addressed store, hash-verified

463// // Handle other errors
464// }
465func IsCode(err error, code ErrorCode) bool {
466 if e, ok := err.(*Error); ok {
467 return e.Code == code
468 }
469 return false
470}
471
472// GetCode returns the error code from an error, or empty string if not a structured error.
473//

Callers 7

Example_errorRecoveryFunction · 0.92
Example_errorCodesFunction · 0.92
TestErrorCodeExtractionFunction · 0.92
TestIsCodeFunction · 0.85

Calls

no outgoing calls

Tested by 7

Example_errorRecoveryFunction · 0.74
Example_errorCodesFunction · 0.74
TestErrorCodeExtractionFunction · 0.74
TestIsCodeFunction · 0.68