Skip to content

Commit

Permalink
Merge pull request #26 from duplocloud/DUPLO-13650-remove-nil-from-va…
Browse files Browse the repository at this point in the history
…lid-error-message

DUPLO-13650 Elide err when nil from fatal messages
  • Loading branch information
joek-duplo authored Jan 26, 2024
2 parents b4a6fd0 + 0e883b6 commit bdbe889
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 2024-01-24

### Fixed
- Improved error message format when a tenant is missing or not allowed.
- Prevented appending a nil error object to fatal error messages.
4 changes: 2 additions & 2 deletions cmd/duplo-jit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func GetTenantIdAndName(tenantIDorName string, client *duplocloud.Client) (strin
tenantName = tenantIDorName
tenant, err := client.GetTenantByNameForUser(tenantName)
if tenant == nil || err != nil {
internal.Fatal(fmt.Sprintf("%s: tenant missing or not allowed", tenantName), err)
internal.Fatal(fmt.Sprintf("tenant '%s' missing or not allowed", tenantName), err)
} else {
tenantID = tenant.TenantID
}
Expand All @@ -234,7 +234,7 @@ func GetTenantIdAndName(tenantIDorName string, client *duplocloud.Client) (strin
tenantID = tenantIDorName
tenant, err := client.GetTenantForUser(tenantIDorName)
if tenant == nil || err != nil {
internal.Fatal(fmt.Sprintf("%s: tenant missing or not allowed", tenantID), err)
internal.Fatal(fmt.Sprintf("tenant '%s' missing or not allowed", tenantID), err)
} else {
tenantName = tenant.AccountName
}
Expand Down
5 changes: 4 additions & 1 deletion internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ func DieIf(err error, msg string) {
}

func Fatal(msg string, err error) {
log.Fatalf("%s: %s: %s", os.Args[0], msg, err)
if err != nil {
log.Fatalf("%s: %s: %s", os.Args[0], msg, err)
}
log.Fatalf("%s: %s", os.Args[0], msg)
}

0 comments on commit bdbe889

Please sign in to comment.