Class CommandFailedEvent

java.lang.Object
com.mongodb.event.CommandEvent
com.mongodb.event.CommandFailedEvent

public final class CommandFailedEvent extends CommandEvent
An event representing the failure of a MongoDB database command.
Since:
3.1
  • Constructor Details

    • CommandFailedEvent

      public CommandFailedEvent(@Nullable RequestContext requestContext, long operationId, int requestId, ConnectionDescription connectionDescription, String databaseName, String commandName, long elapsedTimeNanos, Throwable throwable)
      Construct an instance.
      Parameters:
      requestContext - the request context
      operationId - the operation id
      requestId - the request id
      connectionDescription - the connection description
      databaseName - the database name
      commandName - the command name
      elapsedTimeNanos - the non-negative elapsed time in nanoseconds for the operation to complete
      throwable - the throwable cause of the failure
      Since:
      4.11
  • Method Details

    • getElapsedTime

      public long getElapsedTime(TimeUnit timeUnit)
      Gets the elapsed time in the given unit of time.
      Parameters:
      timeUnit - the time unit in which to get the elapsed time
      Returns:
      the elapsed time
    • getThrowable

      public Throwable getThrowable()
      Gets the throwable cause of the failure
      Returns:
      the throwable cause of the failure