Hi James,
Per mongo/error_codes.yml at master · mongodb/mongo · GitHub, the error code for this error is 86. Given this, you can type-cast your error to mongo.CommandError and check that the Code field is 86 or that the Name field is IndexKeySpecsConflict.