Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-773

Improve context of 'document is nil' errors

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 0.2.0
    • Component/s: Error Handling
    • Labels:
    • Hide

      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?

      Show
      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?

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: