Skip to content

Commit

Permalink
Handle file write errors separately
Browse files Browse the repository at this point in the history
Previously, errors when writing "chain.pem" and "signing_key.pem" were not handled separately. This change ensures that each file write operation checks for errors independently and exits with an error message if a write fails.
  • Loading branch information
rolandgroen committed Oct 14, 2024
1 parent b093d0f commit 976057c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ func main() {
os.Exit(-1)
}

os.WriteFile("chain.pem", chainPems, 0644)
os.WriteFile("signing_key.pem", signingKeyPem, 0644)

err = os.WriteFile("chain.pem", chainPems, 0644)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
err = os.WriteFile("signing_key.pem", signingKeyPem, 0644)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}

default:
fmt.Println("Unknown command")
os.Exit(-1)
Expand Down

0 comments on commit 976057c

Please sign in to comment.