Selaa lähdekoodia

fix nil check, wrap errors

Signed-off-by: Sean Holcomb <seanholcomb@gmail.com>
Sean Holcomb 2 vuotta sitten
vanhempi
sitoutus
5aea593237
1 muutettua tiedostoa jossa 9 lisäystä ja 9 poistoa
  1. 9 9
      pkg/cloud/aws/athenaconfiguration.go

+ 9 - 9
pkg/cloud/aws/athenaconfiguration.go

@@ -133,45 +133,45 @@ func (ac *AthenaConfiguration) UnmarshalJSON(b []byte) error {
 
 	bucket, err := config.GetInterfaceValue[string](fmap, "bucket")
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Bucket = bucket
 
 	region, err := config.GetInterfaceValue[string](fmap, "region")
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Region = region
 
 	database, err := config.GetInterfaceValue[string](fmap, "database")
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Database = database
 
 	if _, ok := fmap["catalog"]; ok {
 		catalog, err := config.GetInterfaceValue[string](fmap, "catalog")
-		if err == nil {
-			return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		if err != nil {
+			return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 		}
 		ac.Catalog = catalog
 	}
 
 	table, err := config.GetInterfaceValue[string](fmap, "table")
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Table = table
 
 	workgroup, err := config.GetInterfaceValue[string](fmap, "workgroup")
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Workgroup = workgroup
 
 	account, err := config.GetInterfaceValue[string](fmap, "account")
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Account = account
 
@@ -181,7 +181,7 @@ func (ac *AthenaConfiguration) UnmarshalJSON(b []byte) error {
 	}
 	authorizer, err := config.AuthorizerFromInterface(authAny, SelectAuthorizerByType)
 	if err != nil {
-		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %s", err.Error())
+		return fmt.Errorf("AthenaConfiguration: UnmarshalJSON: %w", err)
 	}
 	ac.Authorizer = authorizer