Skip to content

Commit b9afe63

Browse files
committed
chore: refactor common error type
1 parent 43f4766 commit b9afe63

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

internal/branches/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
3030
Branches: branches,
3131
})
3232
case utils.OutputEnv:
33-
return errors.Errorf("--output env flag is not supported")
33+
return errors.New(utils.ErrEnvNotSupported)
3434
}
3535

3636
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, branches)

internal/functions/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs) error {
4545
Functions: *resp.JSON200,
4646
})
4747
case utils.OutputEnv:
48-
return errors.Errorf("--output env flag is not supported")
48+
return errors.New(utils.ErrEnvNotSupported)
4949
}
5050

5151
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, *resp.JSON200)

internal/orgs/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Run(ctx context.Context) error {
3030
Organizations: *resp.JSON200,
3131
})
3232
case utils.OutputEnv:
33-
return errors.Errorf("--output env flag is not supported")
33+
return errors.New(utils.ErrEnvNotSupported)
3434
}
3535

3636
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, *resp.JSON200)

internal/projects/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
6464
Projects: projects,
6565
})
6666
case utils.OutputEnv:
67-
return errors.Errorf("--output env flag is not supported")
67+
return errors.New(utils.ErrEnvNotSupported)
6868
}
6969

7070
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, projects)

internal/secrets/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs) error {
3535
Secrets: secrets,
3636
})
3737
case utils.OutputEnv:
38-
return errors.Errorf("--output env flag is not supported")
38+
return errors.New(utils.ErrEnvNotSupported)
3939
}
4040

4141
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, secrets)

internal/services/services.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
"github.com/supabase/cli/pkg/queue"
1616
)
1717

18-
var ErrEnvNotSupported = errors.New("--output env flag is not supported")
19-
2018
func Run(ctx context.Context, fsys afero.Fs) error {
2119
if err := flags.LoadProjectRef(fsys); err != nil && !errors.Is(err, utils.ErrNotLinked) {
2220
fmt.Fprintln(os.Stderr, err)
@@ -46,7 +44,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
4644
Services: serviceImages,
4745
})
4846
case utils.OutputEnv:
49-
return errors.New(ErrEnvNotSupported)
47+
return errors.New(utils.ErrEnvNotSupported)
5048
}
5149

5250
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, serviceImages)

internal/services/services_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestServicesCommand(t *testing.T) {
4646
// Run test
4747
err := Run(context.Background(), afero.NewMemMapFs())
4848
// Check error
49-
assert.ErrorIs(t, err, ErrEnvNotSupported)
49+
assert.ErrorIs(t, err, utils.ErrEnvNotSupported)
5050
})
5151
}
5252

internal/snippets/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
4040
}
4141
return utils.RenderTable(table)
4242
case utils.OutputEnv:
43-
return errors.Errorf("--output env flag is not supported")
43+
return errors.New(utils.ErrEnvNotSupported)
4444
}
4545

4646
return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, *resp.JSON200)

internal/sso/get/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func Run(ctx context.Context, ref, providerId, format string) error {
3737
case utils.OutputPretty:
3838
return render.SingleMarkdown(*resp.JSON200)
3939
case utils.OutputEnv:
40-
return errors.Errorf("--output env flag is not supported")
40+
return errors.New(utils.ErrEnvNotSupported)
4141
default:
4242
return utils.EncodeOutput(format, os.Stdout, resp.JSON200)
4343
}

internal/utils/output.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ var OutputFormat = EnumFlag{
3838
Value: OutputPretty,
3939
}
4040

41+
var ErrEnvNotSupported = errors.New("--output env flag is not supported")
42+
4143
func EncodeOutput(format string, w io.Writer, value any) error {
4244
switch format {
4345
case OutputEnv:

0 commit comments

Comments
 (0)