Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1433

OperationError#code not set on duplicate key error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.0.rc0, 2.6.4
    • Affects Version/s: 2.6.0
    • Component/s: None
    • None
    • Environment:
      Tested on MongoDB 3.4 and 3.6 with Ruby 2.5 and JRuby 9.2.0.0

      On certain kinds of errors like duplicate key errors, no code is set on the OperationError exception. 

      Steps to reproduce:

      require 'mongo'
      client = Mongo::Client.new("mongodb://localhost/test")
      
      begin
        client['test'].insert_one(_id: '1')
        client['test'].insert_one(_id: '1')
      rescue => e
        puts "Code: #{e.code.inspect}"
      end
      

      Expected Result:

      Prints "Code 11000"

      Actual Result:

      Prints "Code nil"

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            helle@fraggaz.de Andreas Gerauer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: