Skip to content

Commit

Permalink
Improve some error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Jul 30, 2023
1 parent 27b73c5 commit e5bc769
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ func main() {
}
state, err := base64.RawStdEncoding.DecodeString(resume)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error decoding the resume state: %v\n", err)
os.Exit(1)
}
h = sha256.New()
err = hashUnmarshalBinary(&h, state)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error unmarshaling the resume state: %v\n", err)
os.Exit(1)
}
position = hashGetLen(h)
Expand Down Expand Up @@ -160,7 +160,7 @@ func main() {
lastPosition = position
state, err := hashMarshalBinary(h)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error marshaling the resume state: %v\n", err)
os.Exit(1)
}
if state == nil {
Expand Down Expand Up @@ -201,7 +201,7 @@ func main() {
if caBundle != "" {
f, err := os.Open(caBundle)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error opening the CA bundle: %v\n", err)
os.Exit(1)
}
o.CustomCABundle = f
Expand All @@ -226,7 +226,7 @@ func main() {
}),
)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error initializing the AWS SDK: %v\n", err)
os.Exit(1)
}
client := s3.NewFromConfig(cfg,
Expand Down Expand Up @@ -269,7 +269,8 @@ func main() {
Bucket: aws.String(bucket),
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error getting bucket region: %v\n", err)
fmt.Fprintln(os.Stderr, "Try adding --region.")
os.Exit(1)
}
bucketLocations[bucket] = normalizeBucketLocation(bucketLocationOutput.LocationConstraint)
Expand Down Expand Up @@ -331,7 +332,7 @@ func main() {
fmt.Fprintln(os.Stderr)
state, err := hashMarshalBinary(h)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, "Error marshaling the resume state: %v\n", err)
os.Exit(1)
}
encodedState := base64.RawStdEncoding.EncodeToString(state)
Expand Down

0 comments on commit e5bc769

Please sign in to comment.