Class WriteConcernError


  • public class WriteConcernError
    extends java.lang.Object
    An error representing a failure by the server to apply the requested write concern to the bulk operation.
    Since:
    3.0
    MongoDB documentation
    Write Concern
    • Constructor Summary

      Constructors 
      Constructor Description
      WriteConcernError​(int code, java.lang.String codeName, java.lang.String message, org.bson.BsonDocument details)
      Constructs a new instance.
      WriteConcernError​(int code, java.lang.String codeName, java.lang.String message, org.bson.BsonDocument details, java.util.Set<java.lang.String> errorLabels)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLabel​(java.lang.String errorLabel)
      Adds the given error label to the exception.
      boolean equals​(java.lang.Object o)  
      int getCode()
      Gets the code associated with this error.
      java.lang.String getCodeName()
      Gets the name associated with the error code.
      org.bson.BsonDocument getDetails()
      Gets the details associated with this error.
      java.util.Set<java.lang.String> getErrorLabels()
      Gets the set of error labels associated with this exception.
      java.lang.String getMessage()
      Gets the message associated with this error.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WriteConcernError

        public WriteConcernError​(int code,
                                 java.lang.String codeName,
                                 java.lang.String message,
                                 org.bson.BsonDocument details)
        Constructs a new instance.
        Parameters:
        code - the error code
        codeName - the error code name
        message - the error message
        details - any details
      • WriteConcernError

        public WriteConcernError​(int code,
                                 java.lang.String codeName,
                                 java.lang.String message,
                                 org.bson.BsonDocument details,
                                 java.util.Set<java.lang.String> errorLabels)
        Constructs a new instance.
        Parameters:
        code - the error code
        codeName - the error code name
        message - the error message
        details - any details
        errorLabels - any error labels
        Since:
        4.1
    • Method Detail

      • getCode

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

        public java.lang.String getCodeName()
        Gets the name associated with the error code.
        Returns:
        the error code name, which may be the empty string
        Since:
        3.8
        Since server release
        3.4
      • getMessage

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

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

        public void addLabel​(java.lang.String errorLabel)
        Adds the given error label to the exception.
        Parameters:
        errorLabel - the non-null error label to add to the exception
        Since:
        4.1
      • getErrorLabels

        @NonNull
        public java.util.Set<java.lang.String> getErrorLabels()
        Gets the set of error labels associated with this exception.
        Returns:
        the error labels, which may not be null but may be empty
        Since:
        4.1
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object