Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3604

ObjectsGetResponse "double" error handling

$
0
0

Hello, I am just a bit confused about Weaviate’s choices in error handling within object response. Specifically, when attempting to flush a batch.

I had the following code (in golang):

	response, err := batcher.Do(ctx) // batcher is *batch.ObjectsBatcher
	if err != nil {
		return nil, err
	}

And everything worked well up until I had made a mistake, by providing a bit different object which didn’t abide by my originally set up BatchObject properties, thus causing an error. In the case above I would have expected to see an error in err variable that would terminate the program. However, it didn’t really happen. Instead I had to spend a significant amount of time to discover that I need to iterate through the response objects to identify the error since it didn’t appear anywhere:

	responses, err := batcher.Do(ctx)
	if err != nil {
		return nil, err
	}

	for _, resp := range responses {
		for _, errItem := range resp.Result.Errors.Error {
			if errItem != nil {
				log.Println("Batch error message:", errItem.Message)
			}
		}
	}

Why such choice of “double” error handling is needed in weaviate?

Seems very inefficient from development side, that just makes the code less readable. Furthermore, I didn’t really see anywhere in documentation addressing this issue of how to properly handle such errors, but it may be my fault of not being careful enough.

I would expect that the error handling is included within the .Do(context) method, just so the development is easier in future.


Viewing all articles
Browse latest Browse all 3604

Trending Articles