Skip to content

Commit

Permalink
send correct message from civogo sdk when api key is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
dipu989 committed Sep 24, 2024
1 parent 6af71f6 commit 3eead7b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ var (
VolumeInvalidSizeError = constError("VolumeInvalidSizeError")

DatabaseAccountDestroyError = constError("DatabaseAccountDestroyError")
DatabaseAccountNotFoundError = constError("DatabaseAccountNotFoundError")
DatabaseAccountAccessDeniedError = constError("DatabaseAccountAccessDeniedError")
DatabaseCreatingAccountError = constError("DatabaseCreatingAccountError")

// Invalid API Key Error
InvalidAPIKeyError = constError("InvalidAPIKeyError")

DatabaseUpdatingAccountError = constError("DatabaseUpdatingAccountError")
DatabaseAccountStatsError = constError("DatabaseAccountStatsError")
DatabaseActionListingError = constError("DatabaseActionListingError")
Expand Down Expand Up @@ -396,8 +398,9 @@ func decodeError(err error) error {
err := errors.New(msg.String())
return DatabaseAccountDestroyError.wrap(err)
case "database_account_not_found":
err := errors.New(msg.String())
return DatabaseAccountNotFoundError.wrap(err)
msg := "API Key is invalid, please visit https://dashboard.civo.com/security to generate a new one"
err := errors.New(msg)
return InvalidAPIKeyError.wrap(err)
case "database_account_access_denied":
err := errors.New(msg.String())
return DatabaseAccountAccessDeniedError.wrap(err)
Expand Down

0 comments on commit 3eead7b

Please sign in to comment.