Skip to content

Commit 9761a9a

Browse files
authored
Mark some more errors as user errors (#578)
## Summary So that they're not reported to Sentry. ## How was it tested? ``` DO_NOT_TRACK=0 devbox run invalid-script ```
1 parent 989335f commit 9761a9a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/boxcli/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/spf13/cobra"
99
"go.jetpack.io/devbox"
1010
"go.jetpack.io/devbox/internal/boxcli/featureflag"
11+
"go.jetpack.io/devbox/internal/boxcli/usererr"
1112
"go.jetpack.io/devbox/internal/debug"
1213
)
1314

@@ -73,7 +74,7 @@ func parseScriptArgs(args []string, flags runCmdFlags) (string, string, []string
7374
scriptArgs = args[1:]
7475
} else {
7576
// this should never happen because cobra should prevent it, but it's better to be defensive.
76-
return "", "", nil, errors.New("no command or script provided")
77+
return "", "", nil, usererr.New("no command or script provided")
7778
}
7879

7980
return path, script, scriptArgs, nil

internal/impl/devbox.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (d *Devbox) RunScriptInNewNixShell(scriptName string) error {
306306
nixShellFilePath := filepath.Join(d.projectDir, ".devbox/gen/shell.nix")
307307
script := d.cfg.Shell.Scripts[scriptName]
308308
if script == nil {
309-
return errors.Errorf("unable to find a script with name %s", scriptName)
309+
return usererr.New("unable to find a script with name %s", scriptName)
310310
}
311311

312312
pluginHooks, err := plugin.InitHooks(d.cfg.Packages, d.projectDir)
@@ -349,7 +349,7 @@ func (d *Devbox) RunScriptInShell(scriptName string) error {
349349

350350
script := d.cfg.Shell.Scripts[scriptName]
351351
if script == nil {
352-
return errors.Errorf("unable to find a script with name %s", scriptName)
352+
return usererr.New("unable to find a script with name %s", scriptName)
353353
}
354354

355355
shell, err := nix.DetectShell(

0 commit comments

Comments
 (0)