From 2a0c683c12e843736dd42eee713803978364b62f Mon Sep 17 00:00:00 2001 From: Asdine El Hrychy Date: Mon, 2 Dec 2024 17:06:54 +0400 Subject: [PATCH] display clear derived error --- apps/multi-tenancy-activate-deactivate/run.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/multi-tenancy-activate-deactivate/run.go b/apps/multi-tenancy-activate-deactivate/run.go index fe901787..cafa6dcf 100644 --- a/apps/multi-tenancy-activate-deactivate/run.go +++ b/apps/multi-tenancy-activate-deactivate/run.go @@ -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.") @@ -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.") @@ -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).