The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MongoDB::Error - MongoDB Driver Error classes

VERSION

version v0.999.998.2

SYNOPSIS

    use MongoDB::Error;

    MongoDB::Error->throw("a generic error");

    MongoDB::DatabaseError->throw(
        message => $string,
        result => $hashref,
    );

DESCRIPTION

This class defines a heirarchy of exception objects.

METHODS

throw

    MongoDB::Error->throw( "message" );
    MongoDB::Error->throw( message => "message" );
    MongoDB::Error->throw( $error_object );

EXCEPTION HIERARCHY

    MongoDB::Error
        |
        |->MongoDB::ConnectionError
        |   |
        |   |->MongoDB::HandshakeError
        |   |
        |   |->MongoDB::NetworkError
        |
        |->MongoDB::DatabaseError
        |   |
        |   |->MongoDB::DuplicateKeyError
        |   |
        |   |->MongoDB::NotMasterError
        |   |
        |   |->MongoDB::WriteError
        |   |
        |   |->MongoDB::WriteConcernError
        |
        |->MongoDB::TimeoutError
        |   |
        |   |->MongoDB::ExecutionTimeout
        |   |
        |   |->MongoDB::NetworkTimeout
        |
        |->MongoDB::CursorNotFoundError
        |
        |->MongoDB::DocumentError
        |
        |->MongoDB::ProtocolError
        |
        |->MongoDB::SelectionError
        |
        |->MongoDB::InternalError

All classes inherit from MongoDB::Error.

All error classes have the attribute:

  • message — a text representation of the error

MongoDB::ConnectionError

Errors related to network connections.

MongoDB::HandshakeError

This error is thrown when a connection has been made, but SSL or authentication handshakes fail.

MongoDB::NetworkError

This error is thrown when a socket error occurs, when the wrong number of bytes are read, or other wire-related errors occur.

MongoDB::DatabaseError

Errors related to database operations. Specifically, when an error of this type occurs, the driver has received an error condition from the server.

Attributes include:

  • result — response from a database command; this must impliement the last_errmsg method

MongoDB::DuplicateKeyError

This error indicates that a write attempted to create a document with a duplicate key in a collection with a unique index. The result attribute is a result object.

MongoDB::NotMasterError

This error indicates that a write or other state-modifying operation was attempted on a server that was not a primary. The result attribute is a MongoDB::CommandResult object.

MongoDB::WriteError

Errors indicating failure of a write command. The result attribute is a result object.

MongoDB::WriteConcernError

Errors indicating failure of a write concern. The result attribute is a result object.

MongoDB::TimeoutError

These errors indicate a user-specified timeout has been exceeded.

MongoDB::ExecutionTimeout

This error is thrown when a query or command fails because max_time_ms has been reached. The result attribute is a MongoDB::CommandResult object.

MongoDB::NetworkTimeout

This error is thrown when a network operation exceeds a timeout, typically connect_timeout_ms or socket_timeout_ms.

MongoDB::CursorNotFoundError

This error indicates that a cursor timed out on a server.

MongoDB::DocumentError

This error indicates a problem with a document to be inserted or replaced into the database.

Attributes include:

  • document — the document that caused the error

MongoDB::InternalError

Errors that indicate problems in the driver itself, typically when something unexpected is detected. These should be reported as potential bugs.

MongoDB::ProtocolError

Errors related to the MongoDB wire protocol, typically problems parsing a database response packet.

MongoDB::SelectionError

When server selection fails for a given operation, this is thrown. For example, attempting a write when no primary is available or reading with a specific mode and tag set and no servers match.

AUTHORS

  • David Golden <david@mongodb.com>

  • Mike Friedman <friedo@mongodb.com>

  • Kristina Chodorow <kristina@mongodb.com>

  • Florian Ragwitz <rafl@debian.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by MongoDB, Inc..

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004