Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-709

Define mongoc_error_code_t value for "duplicate key error"

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.0
    • Affects Version/s: None
    • Component/s: Docs, errors
    • None
    • Environment:

      I would like to code our application to trap on this bson_error_t returned by mongoc_collection_insert():

      domain: 11
      code: 11000
      message: insertDocument :: caused by :: 11000 E11000 duplicate key error index: DSC_service1_DBNAME.TABLENAME.$_id_  dup key: { : "SDF" }
      

      However I don't want to put "magic numbers" in our code, like this:

      if (error.code == 11000)
      

      I would like to code it like this:

      if (error.code == SOME_ENUMERATION_FOR_DUPLICATE_KEY)
      

      Where do I find the enumeration?

      Thanks,
      Barry

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            mongodb-support Ulticom
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: