diff options
Diffstat (limited to 'internal/bootstrap')
-rw-r--r-- | internal/bootstrap/starter/starter.go | 7 | ||||
-rw-r--r-- | internal/bootstrap/starter/starter_test.go | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/internal/bootstrap/starter/starter.go b/internal/bootstrap/starter/starter.go index 7c43781af..a8b7c018c 100644 --- a/internal/bootstrap/starter/starter.go +++ b/internal/bootstrap/starter/starter.go @@ -23,7 +23,8 @@ const ( ) var ( - errEmptySchema = errors.New("empty schema can't be used") + // ErrEmptySchema signals that the address has no schema in it. + ErrEmptySchema = errors.New("empty schema can't be used") errEmptyAddress = errors.New("empty address can't be used") ) @@ -36,7 +37,7 @@ func ParseEndpoint(endpoint string) (Config, error) { parts := strings.Split(endpoint, separator) if len(parts) != 2 { - return Config{}, fmt.Errorf("unsupported format: %q", endpoint) + return Config{}, fmt.Errorf("unsupported format: %q: %w", endpoint, ErrEmptySchema) } if err := verifySchema(parts[0]); err != nil { @@ -65,7 +66,7 @@ func ComposeEndpoint(schema, address string) (string, error) { func verifySchema(schema string) error { switch schema { case "": - return errEmptySchema + return ErrEmptySchema case TCP, TLS, Unix: return nil default: diff --git a/internal/bootstrap/starter/starter_test.go b/internal/bootstrap/starter/starter_test.go index 7347d0e13..c5d84b1f8 100644 --- a/internal/bootstrap/starter/starter_test.go +++ b/internal/bootstrap/starter/starter_test.go @@ -2,6 +2,7 @@ package starter import ( "errors" + "fmt" "testing" "github.com/stretchr/testify/require" @@ -110,12 +111,12 @@ func TestParseEndpoint(t *testing.T) { { desc: "no schema", addr: "://127.0.0.1:2306", - expErr: errEmptySchema, + expErr: ErrEmptySchema, }, { desc: "bad format", addr: "127.0.0.1:2306", - expErr: errors.New(`unsupported format: "127.0.0.1:2306"`), + expErr: fmt.Errorf(`unsupported format: "127.0.0.1:2306": %w`, ErrEmptySchema), }, { desc: "tcp schema addresses", |