[GODRIVER-773] Improve context of 'document is nil' errors Created: 17/Jan/19  Updated: 06/Feb/23  Resolved: 06/Feb/23

Status: Closed
Project: Go Driver
Component/s: Error Handling
Affects Version/s: 0.2.0
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: David Golden Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates GODRIVER-1854 Make "ErrNilDocument" and "ErrNilValu... Backlog
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

In converting tools from 0.1.0 to 0.2.0, I have to fix many 'document is nil' errors now that nil can't be use for an empty document. The problem is that the error message has no additional context that would make it easier to tell what function has the problem.

For example: here's code from Find:

 

	f, err := transformDocument(coll.registry, filter)
	if err != nil {
		return nil, err
	}

It would help users debug if they had additional context like this:

	f, err := transformDocument(coll.registry, filter)
	if err != nil {
		return nil, fmt.Errorf("invalid filter in Find: %v", err) 
	}

This lack of context is probably in many more places – but the scope of this ticket is intended to cover invalid use of nil documents.



 Comments   
Comment by Dylan Parker [ 29/Jan/19 ]

Just an observation but transformDocument can also return a MarshalError as well so there would have to be additional type checking.

Generated at Thu Feb 08 08:34:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.