Skip to content

MongoTimeoutException

class MongoTimeoutException(
    val timeout: Duration?, 
    message: String = if (timeout != null) "Operation timed out after $timeout" else "Operation timed out", 
    response: BsonDocument?, 
    request: BsonDocument?, 
    server: MongoException.ServerAddress?, 
    command: Command, 
    namespace: String, 
    cause: Throwable? = null
) : MongoException

An operation failed because it took longer than a specified timeout.

For example, the timeout could have been configured with the HasMaxTime.maxTime option.

Constructors

MongoTimeoutException

constructor(
    timeout: Duration?, 
    message: String = if (timeout != null) "Operation timed out after $timeout" else "Operation timed out", 
    response: BsonDocument?, 
    request: BsonDocument?, 
    server: MongoException.ServerAddress?, 
    command: Command, 
    namespace: String, 
    cause: Throwable? = null
)

Properties

cause

expect open val cause: Throwable?

command

The command that was being executed when this exception occurred, from the point of view of KtMongo.

The various drivers have preprocessing steps that modify the command before it is sent, so this field may not exactly contain what the database received.

For example, the option readPreference is never sent to the database, as it specifies which replica the driver should send the message to.

To see the exact command sent to the database, see request, if present.

message

expect open val message: String?

namespace

The database or collection that was being accessed when this exception occurred.

request

If this exception corresponds to the sending of a database request, this field contains that request.

Note that the official drivers do not provide easy access to the exact request that was sent, so this field may often be null when using it.

response

If this exception corresponds to the processing of a database response, this field contains that response.

server

The address of the server that was being contacted when this exception occurred.

When connected to a replica set, this contains the specific replica set member that lead to this exception.

timeout