@@ -18,6 +18,7 @@ package cmd
1818
1919import (
2020 "fmt"
21+ "net/url"
2122
2223 s "github.com/cortexlabs/cortex/pkg/lib/strings"
2324)
@@ -31,23 +32,25 @@ type ErrorKind int
3132
3233const (
3334 ErrUnknown ErrorKind = iota
34- ErrCliAlreadyInAppDir
35+ ErrCLIAlreadyInAppDir
3536 ErrAPINotReady
3637 ErrAPINotFound
37- ErrFailedToConnect
38- ErrCliNotInAppDir
38+ ErrFailedToConnectURL
39+ ErrFailedToConnectOperator
40+ ErrCLINotInAppDir
3941)
4042
4143var errorKinds = []string {
4244 "err_unknown" ,
4345 "err_cli_already_in_app_dir" ,
4446 "err_api_not_ready" ,
4547 "err_api_not_found" ,
46- "err_failed_to_connect" ,
48+ "err_failed_to_connect_url" ,
49+ "err_failed_to_connect_operator" ,
4750 "err_cli_not_in_app_dir" ,
4851}
4952
50- var _ = [1 ]int {}[int (ErrCliNotInAppDir )- (len (errorKinds )- 1 )] // Ensure list length matches
53+ var _ = [1 ]int {}[int (ErrCLINotInAppDir )- (len (errorKinds )- 1 )] // Ensure list length matches
5154
5255func (t ErrorKind ) String () string {
5356 return errorKinds [t ]
@@ -94,7 +97,7 @@ func (e Error) Error() string {
9497
9598func ErrorCliAlreadyInAppDir (dirPath string ) error {
9699 return Error {
97- Kind : ErrCliAlreadyInAppDir ,
100+ Kind : ErrCLIAlreadyInAppDir ,
98101 message : fmt .Sprintf ("your current working directory is already in a cortex directory (%s)" , dirPath ),
99102 }
100103}
@@ -113,16 +116,24 @@ func ErrorAPINotFound(apiName string) error {
113116 }
114117}
115118
116- func ErrorFailedToConnect (urlStr string ) error {
119+ func ErrorFailedConnectURL (url url.URL ) error {
120+ url .RawQuery = ""
117121 return Error {
118- Kind : ErrFailedToConnect ,
122+ Kind : ErrFailedToConnectURL ,
123+ message : "failed to connect to " + url .String (),
124+ }
125+ }
126+
127+ func ErrorFailedToConnectOperator (urlStr string ) error {
128+ return Error {
129+ Kind : ErrFailedToConnectOperator ,
119130 message : fmt .Sprintf ("failed to connect to the operator (%s), run `cortex configure` if you need to update the operator URL" , urlStr ),
120131 }
121132}
122133
123134func ErrorCliNotInAppDir () error {
124135 return Error {
125- Kind : ErrCliNotInAppDir ,
136+ Kind : ErrCLINotInAppDir ,
126137 message : "your current working directory is not in or under a cortex directory (identified via a top-level cortex.yaml file)" ,
127138 }
128139}
0 commit comments