File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ func (e ErrNotSupported[T]) Is(target error) bool {
2626 return ok
2727}
2828
29+ type ErrUnrecognizedResponse [T StringLike ] struct {
30+ Actual T
31+ Expected T
32+ }
33+
34+ func (e ErrUnrecognizedResponse [T ]) Error () string {
35+ return fmt .Sprintf ("unrecognized response. expected: %s (or na). got: %s" , e .Expected , e .Actual )
36+ }
37+
2938// ErrNoProtocols is the error returned when the no protocols have been
3039// specified.
3140var ErrNoProtocols = errors .New ("no protocols specified" )
@@ -146,6 +155,9 @@ func readProto[T StringLike](proto T, r io.Reader) error {
146155 case "na" :
147156 return ErrNotSupported [T ]{[]T {proto }}
148157 default :
149- return fmt .Errorf ("unrecognized response: %s" , tok )
158+ return ErrUnrecognizedResponse [T ]{
159+ Actual : tok ,
160+ Expected : proto ,
161+ }
150162 }
151163}
You can’t perform that action at this time.
0 commit comments