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)
| 463 | // // Handle other errors |
| 464 | // } |
| 465 | func 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 | // |
no outgoing calls