cmd: Print error if fmt overwrite fails (fix #4524)

This commit is contained in:
Matthew Holt 2022-01-16 17:30:07 -07:00
parent 1feb65952a
commit 1a7a78a1f2
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -567,7 +567,7 @@ func cmdFmt(fl Flags) (int, error) {
if fl.Bool("overwrite") {
if err := os.WriteFile(formatCmdConfigFile, output, 0600); err != nil {
return caddy.ExitCodeFailedStartup, nil
return caddy.ExitCodeFailedStartup, fmt.Errorf("overwriting formatted file: %v", err)
}
} else {
fmt.Print(string(output))