Package com.mongodb

Class MongoException

    • Constructor Summary

      Constructors 
      Constructor Description
      MongoException​(int code,  msg)  
      MongoException​(int code,  msg,  t)  
       msg)  
       msg,  t)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void  errorLabel)
      Adds the given error label to the exception.
      static MongoException  t)
      Static helper to create or cast a MongoException from a throwable
      static MongoException  t)
      Static helper to create or cast a MongoException from a throwable
      int getCode()
      Gets the exception code
      <> getErrorLabels()
      Gets the set of error labels associated with this exception.
      boolean  errorLabel)
      Return true if the exception is labelled with the given error label, and false otherwise.
      void  errorLabel)
      Removes the given error label from the exception.
      • Methods inherited from class java.lang.

        , , , , , , , , , , , ,
      • Methods inherited from class java.lang.

        , , , , , , , , ,
    • Field Detail

      • TRANSIENT_TRANSACTION_ERROR_LABEL

        public static final  TRANSIENT_TRANSACTION_ERROR_LABEL
        An error label indicating that the exception can be treated as a transient transaction error.
        Since:
        3.8
        See Also:
        hasErrorLabel(String), Constant Field Values
      • UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL

        public static final  UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL
        An error label indicating that the exception can be treated as an unknown transaction commit result.
        Since:
        3.8
        See Also:
        hasErrorLabel(String), Constant Field Values
    • Constructor Detail

      • MongoException

        public MongoException​( msg)
        Parameters:
        msg - the message
      • MongoException

        public MongoException​(int code,
                               msg)
        Parameters:
        code - the error code
        msg - the message
      • MongoException

        public MongoException​( msg,
                               t)
        Parameters:
        msg - the message
        t - the throwable cause
      • MongoException

        public MongoException​(int code,
                               msg,
                               t)
        Parameters:
        code - the error code
        msg - the message
        t - the throwable cause
    • Method Detail

      • fromThrowable

        @Nullable
        public static MongoException fromThrowable​(@Nullable
                                                    t)
        Static helper to create or cast a MongoException from a throwable
        Parameters:
        t - a throwable, which may be null
        Returns:
        a MongoException
      • fromThrowableNonNull

        public static  t)
        Static helper to create or cast a MongoException from a throwable
        Parameters:
        t - a throwable, which may not be null
        Returns:
        a MongoException
        Since:
        3.7
      • getCode

        public int getCode()
        Gets the exception code
        Returns:
        the error code.
      • addLabel

        public void addLabel​( errorLabel)
        Adds the given error label to the exception.
        Parameters:
        errorLabel - the non-null error label to add to the exception
        Since:
        3.8
      • removeLabel

        public void removeLabel​( errorLabel)
        Removes the given error label from the exception.
        Parameters:
        errorLabel - the non-null error label to remove from the exception
        Since:
        3.8
      • getErrorLabels

        public <> 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:
        3.8
      • hasErrorLabel

        public boolean hasErrorLabel​( errorLabel)
        Return true if the exception is labelled with the given error label, and false otherwise.
        Parameters:
        errorLabel - the non-null error label
        Returns:
        true if the exception is labelled with the given error label
        Since:
        3.8