{
    "content": [
        {
            "type": "text",
            "text": "# MongoDB::Error (perldoc)\n\n## NAME\n\nMongoDB::Error - MongoDB Driver Error classes\n\n## SYNOPSIS\n\nuse MongoDB::Error;\nMongoDB::Error->throw(\"a generic error\");\nMongoDB::DatabaseError->throw(\nmessage => $string,\nresult => $hashref,\n);\n\n## DESCRIPTION\n\nThis class defines a hierarchy of exception objects.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **USAGE**\n- **EXCEPTION HIERARCHY** (13 subsections)\n- **ERROR CODES**\n- **ERROR LABELS**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MongoDB::Error",
        "section": "",
        "mode": "perldoc",
        "summary": "MongoDB::Error - MongoDB Driver Error classes",
        "synopsis": "use MongoDB::Error;\nMongoDB::Error->throw(\"a generic error\");\nMongoDB::DatabaseError->throw(\nmessage => $string,\nresult => $hashref,\n);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "USAGE",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "EXCEPTION HIERARCHY",
                "lines": 52,
                "subsections": [
                    {
                        "name": "MongoDB::AuthError",
                        "lines": 3
                    },
                    {
                        "name": "MongoDB::ConnectionError",
                        "lines": 9
                    },
                    {
                        "name": "MongoDB::ConfigurationError",
                        "lines": 3
                    },
                    {
                        "name": "MongoDB::CursorNotFoundError",
                        "lines": 2
                    },
                    {
                        "name": "MongoDB::DatabaseError",
                        "lines": 24
                    },
                    {
                        "name": "MongoDB::DecodingError",
                        "lines": 3
                    },
                    {
                        "name": "MongoDB::DocumentError",
                        "lines": 7
                    },
                    {
                        "name": "MongoDB::GridFSError",
                        "lines": 2
                    },
                    {
                        "name": "MongoDB::InternalError",
                        "lines": 3
                    },
                    {
                        "name": "MongoDB::ProtocolError",
                        "lines": 3
                    },
                    {
                        "name": "MongoDB::SelectionError",
                        "lines": 4
                    },
                    {
                        "name": "MongoDB::TimeoutError",
                        "lines": 10
                    },
                    {
                        "name": "MongoDB::UsageError",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "ERROR CODES",
                "lines": 27,
                "subsections": []
            },
            {
                "name": "ERROR LABELS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MongoDB::Error - MongoDB Driver Error classes\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version v2.2.2\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use MongoDB::Error;\nMongoDB::Error->throw(\"a generic error\");\nMongoDB::DatabaseError->throw(\nmessage => $string,\nresult => $hashref,\n);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This class defines a hierarchy of exception objects.\n",
                "subsections": []
            },
            "USAGE": {
                "content": "Unless otherwise explicitly documented, all driver methods throw exceptions if an error occurs.\n\nTo catch and handle errors, the Try::Tiny and Safe::Isa modules are recommended:\n\nuse Try::Tiny;\nuse Safe::Isa; # provides $isa\n\ntry {\n$coll->insert( $doc )\n}\ncatch {\nif ( $->$isa(\"MongoDB::DuplicateKeyError\" ) ) {\n...\n}\nelse {\n...\n}\n};\n\nTo retry failures automatically, consider using Try::Tiny::Retry.\n",
                "subsections": []
            },
            "EXCEPTION HIERARCHY": {
                "content": "MongoDB::Error\n|\n|->MongoDB::AuthError\n|\n|->MongoDB::ConnectionError\n|   |\n|   |->MongoDB::HandshakeError\n|   |\n|   |->MongoDB::NetworkError\n|\n|->MongoDB::ConfigurationError\n|\n|->MongoDB::DatabaseError\n|   |\n|   |->MongoDB::CursorNotFoundError\n|   |\n|   |->MongoDB::DuplicateKeyError\n|   |\n|   |->MongoDB::NotMasterError\n|   |\n|   |->MongoDB::WriteError\n|   |\n|   |->MongoDB::WriteConcernError\n|\n|->MongoDB::DecodingError\n|\n|->MongoDB::DocumentError\n|\n|->MongoDB::GridFSError\n|\n|->MongoDB::InternalError\n|\n|->MongoDB::InvalidOperationError\n|\n|->MongoDB::ProtocolError\n|\n|->MongoDB::SelectionError\n|\n|->MongoDB::TimeoutError\n|   |\n|   |->MongoDB::ExecutionTimeout\n|   |\n|   |->MongoDB::NetworkTimeout\n|\n|->MongoDB::UsageError\n\nAll classes inherit from \"MongoDB::Error\".\n\nAll error classes have the attribute:\n\n*   message — a text representation of the error\n",
                "subsections": [
                    {
                        "name": "MongoDB::AuthError",
                        "content": "This error indicates a problem with authentication, either in the underlying mechanism or a\nproblem authenticating with the server.\n"
                    },
                    {
                        "name": "MongoDB::ConnectionError",
                        "content": "Errors related to network connections.\n\nMongoDB::HandshakeError\nThis error is thrown when a connection has been made, but SSL or authentication handshakes fail.\n\nMongoDB::NetworkError\nThis error is thrown when a socket error occurs, when the wrong number of bytes are read, or\nother wire-related errors occur.\n"
                    },
                    {
                        "name": "MongoDB::ConfigurationError",
                        "content": "This error is thrown when there is a configuration error between the MongoDB deployment and the\nconfiguration of the client, such as when trying to use explicit sessions on a MongoDB < 3.6\n"
                    },
                    {
                        "name": "MongoDB::CursorNotFoundError",
                        "content": "This error indicates that a cursor timed out on a server.\n"
                    },
                    {
                        "name": "MongoDB::DatabaseError",
                        "content": "Errors related to database operations. Specifically, when an error of this type occurs, the\ndriver has received an error condition from the server.\n\nAttributes include:\n\n*   result — response from a database command; this must implement the \"lasterrmsg\" method\n\n*   code — numeric error code; see \"ERROR CODES\"; if no code was provided by the database, the\n\"UNKNOWNERROR\" code will be substituted instead\n\nMongoDB::DuplicateKeyError\nThis error indicates that a write attempted to create a document with a duplicate key in a\ncollection with a unique index. The \"result\" attribute is a result object.\n\nMongoDB::NotMasterError\nThis error indicates that a write or other state-modifying operation was attempted on a server\nthat was not a primary. The \"result\" attribute is a MongoDB::CommandResult object.\n\nMongoDB::WriteError\nErrors indicating failure of a write command. The \"result\" attribute is a result object.\n\nMongoDB::WriteConcernError\nErrors indicating failure of a write concern. The \"result\" attribute is a result object.\n"
                    },
                    {
                        "name": "MongoDB::DecodingError",
                        "content": "This error indicates a problem during BSON decoding; it wraps the error provided by the\nunderlying BSON encoder. Note: Encoding errors will be thrown as a \"MongoDB::DocumentError\".\n"
                    },
                    {
                        "name": "MongoDB::DocumentError",
                        "content": "This error indicates a problem with a document to be inserted or replaced into the database, or\nused as an update document.\n\nAttributes include:\n\n*   document — the document that caused the error\n"
                    },
                    {
                        "name": "MongoDB::GridFSError",
                        "content": "Errors related to GridFS operations, such a corrupted file.\n"
                    },
                    {
                        "name": "MongoDB::InternalError",
                        "content": "Errors that indicate problems in the driver itself, typically when something unexpected is\ndetected. These should be reported as potential bugs.\n"
                    },
                    {
                        "name": "MongoDB::ProtocolError",
                        "content": "Errors related to the MongoDB wire protocol, typically problems parsing a database response\npacket.\n"
                    },
                    {
                        "name": "MongoDB::SelectionError",
                        "content": "When server selection fails for a given operation, this is thrown. For example, attempting a\nwrite when no primary is available or reading with a specific mode and tag set and no servers\nmatch.\n"
                    },
                    {
                        "name": "MongoDB::TimeoutError",
                        "content": "These errors indicate a user-specified timeout has been exceeded.\n\nMongoDB::ExecutionTimeout\nThis error is thrown when a query or command fails because \"maxtimems\" has been reached. The\n\"result\" attribute is a MongoDB::CommandResult object.\n\nMongoDB::NetworkTimeout\nThis error is thrown when a network operation exceeds a timeout, typically \"connecttimeoutms\"\nor \"sockettimeoutms\".\n"
                    },
                    {
                        "name": "MongoDB::UsageError",
                        "content": "Indicates invalid arguments or configuration options. Not all usage errors will throw this —\nonly ones originating directly from the MongoDB::* library files. Some type and usage errors\nwill originate from the Type::Tiny library if the objects are used incorrectly.\n\nAlso used to indicate usage errors for transaction commands.\n"
                    }
                ]
            },
            "ERROR CODES": {
                "content": "The following error code constants are automatically exported by this module.\n\nBADVALUE                 => 2,\nUNKNOWNERROR             => 8,\nNAMESPACENOTFOUND       => 26,\nEXCEEDEDTIMELIMIT       => 50,\nCOMMANDNOTFOUND         => 59,\nWRITECONCERNERROR       => 64,\nNOTMASTER                => 10107,\nDUPLICATEKEY             => 11000,\nDUPLICATEKEYUPDATE      => 11001, # legacy before 2.6\nDUPLICATEKEYCAPPED      => 12582, # legacy before 2.6\nUNRECOGNIZEDCOMMAND      => 13390, # mongos error before 2.4\nNOTMASTERNOSLAVEOK    => 13435,\nNOTMASTERORSECONDARY   => 13436,\nCANTOPENDBINREADLOCK => 15927,\n\nThis is a very, very small subset of error codes possible from the server, but covers some of\nthe more common ones seen by drivers.\n\nNote:\n\n*   Only \"MongoDB::DatabaseError\" objects have a \"code\" attribute.\n\n*   The database uses multiple write concern error codes. The driver maps them all to\nWRITECONCERNERROR for consistency and convenience.\n",
                "subsections": []
            },
            "ERROR LABELS": {
                "content": "From MongoDB 4.0 onwards, errors may contain an error labels field. This field is populated for\nextra information from either the server or the driver, depending on the error.\n\nKnown error labels include (but are not limited to):\n\n*   \"TransientTransactionError\" - added when network errors are encountered inside a\ntransaction.\n\n*   \"UnknownTransactionCommitResult\" - added when a transaction commit may not have been able to\nsatisfy the provided write concern.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   David Golden <david@mongodb.com>\n\n*   Rassi <rassi@mongodb.com>\n\n*   Mike Friedman <friedo@friedo.com>\n\n*   Kristina Chodorow <k.chodorow@gmail.com>\n\n*   Florian Ragwitz <rafl@debian.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is Copyright (c) 2020 by MongoDB, Inc.\n\nThis is free software, licensed under:\n\nThe Apache License, Version 2.0, January 2004\n",
                "subsections": []
            }
        }
    }
}