Package com.mongodb

Class WriteError

java.lang.Object
com.mongodb.WriteError
Direct Known Subclasses:
BulkWriteError

public class WriteError extends Object
Represents the details of a write error , e.g. a duplicate key error
Since:
3.0
  • Constructor Details

    • WriteError

      public WriteError(int code, String message, BsonDocument details)
      Constructs a new instance.
      Parameters:
      code - the error code
      message - the error message
      details - details about the error
    • WriteError

      public WriteError(WriteError writeError)
      Construct an instance that is a shallow copy of the given instance.
      Parameters:
      writeError - the write error to copy
  • Method Details

    • getCategory

      public ErrorCategory getCategory()
      Gets the category of this error.
      Returns:
      the category of this write error
    • getCode

      public int getCode()
      Gets the code associated with this error.
      Returns:
      the code
    • getMessage

      public String getMessage()
      Gets the message associated with this error.
      Returns:
      the message
    • getDetails

      public BsonDocument getDetails()
      Gets the details associated with this error. This document will not be null, but may be empty.
      Returns:
      the details
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object