Skip to content

Commit

Permalink
display clear derived error
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Dec 2, 2024
1 parent 706db1e commit 2a0c683
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/multi-tenancy-activate-deactivate/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func updateTentantWithRetry(client *wvt.Client, className string, tenants Tenant
if err == nil {
return err
}
fmt.Printf("Attempt %d/%d failed: %v\n", attempt, maxRetries, err)
fmt.Printf("Attempt %d/%d failed: %v\n", attempt, maxRetries, getErrorWithDerivedError(err))

if attempt == maxRetries {
fmt.Println("Max retries reached. Aborting.")
Expand Down Expand Up @@ -691,7 +691,7 @@ func assertInactiveTenantObjects(client *wvt.Client, className, tenantName strin
if err == nil {
return
}
fmt.Printf("Attempt %d/%d failed: %v\n", attempt, maxRetries, err)
fmt.Printf("Attempt %d/%d failed: %v\n", attempt, maxRetries, getErrorWithDerivedError(err))

if attempt == maxRetries {
fmt.Println("Max retries reached. Aborting.")
Expand All @@ -702,6 +702,18 @@ func assertInactiveTenantObjects(client *wvt.Client, className, tenantName strin
}
}

func getErrorWithDerivedError(err error) error {
switch e := err.(type) {
case *fault.WeaviateClientError:
if e.DerivedFromError != nil {
return fmt.Errorf("%s: %w", e.Error(), e.DerivedFromError)
}
return e
default:
return e
}
}

func isInactiveTenantObjects(client *wvt.Client, className, tenantName string) error {
objects, err := client.Data().ObjectsGetter().
WithClassName(className).
Expand Down

0 comments on commit 2a0c683

Please sign in to comment.