Skip to content

Commit 08bbd77

Browse files
committed
treewide: add non-zero exit codes in more places
1 parent bf7e17e commit 08bbd77

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/cmd/compress/compress.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func CompressProcess(ctx context.Context, args []string) {
7676
}
7777
if openErr != nil {
7878
fmt.Fprintf(os.Stderr, "Error opening output layer: %v\n", openErr)
79+
os.Exit(1)
7980
}
8081

8182
var outputFormat api.LayerFormat

src/cmd/layer/layer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func handleLayerState(
233233
defer func() {
234234
if err := tw.Close(); err != nil {
235235
fmt.Fprintf(os.Stderr, "Error closing tar writer: %v\n", err)
236+
os.Exit(1)
236237
}
237238
}()
238239
if err := tw.Import(casImporter); err != nil {

src/cmd/push/push.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func DeployDispatch(ctx context.Context, rawRequest []byte) {
4646
// Parse os.Args, skipping the program name
4747
if len(os.Args) > 1 {
4848
if err := fs.Parse(os.Args[1:]); err != nil {
49-
// Continue with no additional flags if parsing fails
50-
fmt.Fprintf(os.Stderr, "Warning: failed to parse flags: %v\n", err)
49+
fmt.Fprintf(os.Stderr, "Error: failed to parse flags: %v\n", err)
50+
fs.Usage()
51+
os.Exit(1)
5152
}
5253
}
5354

src/cmd/registry/registry.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ func Run(ctx context.Context, args []string) {
201201
Protocols: protos,
202202
}
203203
fmt.Fprintf(os.Stderr, "Listening on %d\n", porti)
204-
server.Serve(listener)
204+
if err := server.Serve(listener); err != nil && err != http.ErrServerClosed {
205+
log.Fatalf("Failed to serve HTTP server: %v", err)
206+
}
205207
}
206208

207209
func main() {

0 commit comments

Comments
 (0)