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

Include tag key in Unmarshal error message

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • BSON

    Description

      With a type like:

      type toy struct {
           a string `bson:"a"`
           b string `bson:"b"`
      }

      In the snippet below:

      example := &toy{}
      err := bson.Unmarshal(data, example)
      ....
      


      If data contains `a` with a `nil` value, I get the error: "cannot decode null into a string type".

      It would be helpful to get the full field path included in the error message as well.

      Attachments

        Activity

          People

            Unassigned Unassigned
            adinoyi.omuya@mongodb.com Adinoyi Omuya
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: