From f8601357568a3a5d67b4f03832517344e64a27f5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 11 Nov 2019 12:49:33 -0800 Subject: [PATCH] batch serviceusage reads (#255) Signed-off-by: Modular Magician --- google/batcher.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/google/batcher.go b/google/batcher.go index 12a3ac886..85aa0005c 100644 --- a/google/batcher.go +++ b/google/batcher.go @@ -6,6 +6,8 @@ import ( "log" "sync" "time" + + "github.com/hashicorp/errwrap" ) const defaultBatchSendIntervalSec = 10 @@ -154,7 +156,8 @@ func (b *RequestBatcher) SendRequestWithTimeout(batchKey string, request *BatchR select { case resp := <-respCh: if resp.err != nil { - return nil, fmt.Errorf("Batch %q for request %q returned error: %v", batchKey, request.DebugId, resp.err) + // use wrapf so we can potentially extract the original error type + return nil, errwrap.Wrapf(fmt.Sprintf("Batch %q for request %q returned error: {{err}}", batchKey, request.DebugId), resp.err) } return resp.body, nil case <-ctx.Done():