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