mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-20 06:28:13 +00:00
fix(errors): recover retryable/status from wrapped ProxyError
IsRetryable and GetStatusCode used a direct type assertion, so a ProxyError wrapped with %w was never detected (status fell back to 500, retryable to false). Use errors.As, which dereferences the existing Unwrap chain and matches the file's own Unwrap method. Test: Test_IsRetryable_GetStatusCode_Wrapped (wrapped error preserves both flags). Note: these helpers currently have no production callers (test-only surface), so this is a correctness hardening of the error API.
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
@@ -121,7 +122,8 @@ func IsRetryable(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if proxyErr, ok := err.(*ProxyError); ok {
|
||||
var proxyErr *ProxyError
|
||||
if errors.As(err, &proxyErr) {
|
||||
return proxyErr.Retryable
|
||||
}
|
||||
|
||||
@@ -134,7 +136,8 @@ func GetStatusCode(err error) int {
|
||||
return 200
|
||||
}
|
||||
|
||||
if proxyErr, ok := err.(*ProxyError); ok {
|
||||
var proxyErr *ProxyError
|
||||
if errors.As(err, &proxyErr) {
|
||||
return proxyErr.StatusCode
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user