IsContextRelatedError checks if the error is due to context cancellation, deadline exceedance, or closed connection
(ctx context.Context, err error)
| 145 | |
| 146 | // IsContextRelatedError checks if the error is due to context cancellation, deadline exceedance, or closed connection |
| 147 | func IsContextRelatedError(ctx context.Context, err error) bool { |
| 148 | if errors.Is(ctx.Err(), context.Canceled) || errors.Is(ctx.Err(), context.DeadlineExceeded) { |
| 149 | return true |
| 150 | } |
| 151 | if errors.Is(err, context.Canceled) || |
| 152 | errors.Is(err, context.DeadlineExceeded) || |
| 153 | strings.Contains(err.Error(), "conn closed") { |
| 154 | return true |
| 155 | } |
| 156 | return false |
| 157 | } |
| 158 | |
| 159 | // IsSerializationRelatedError checks if the error is a serialization failure, typically in database transactions. |
| 160 | func IsSerializationRelatedError(err error) bool { |
no test coverage detected