Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-299

Introduce new errors and error types

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.1.0
    • Component/s: None
    • Labels:
      None

      Description

      Add definitions for the new error enums and error details structs.

      The errors are as follows:

      ServerError
      commandError(code, message)

      • Thrown when commands that experience errors on the server side that prevent execution
      • From the Write Commands spec: “a command failure, which indicates the command itself did not complete successfully. Example command failures include failure to authorize, failure to parse, operation aborted by user, and unexpected errors during execution (these should be very rare).”

      writeError(write: WriteErrorDetails?, wc: WriteConcernErrorDetails?)

      • Thrown from write commands that experience errors on the server side

      bulkWriteError(writeErrors: [BulkWriteErrorDetails]?, writeConcernError: WriteConcernErrorDetails?, result: BulkWriteResult)

      • Thrown from Bulk write operations that experience errors on the server side

      UserError
      logicError(message)

      • Thrown when user uses the driver in an improper way

      invalidArgument(message)

      • Thrown when receiving an error with code COMMAND_INVALID_ARG from a mongoc call or when we can determine invalid arguments at the Swift level

      RuntimeError
      internalError(message)

      • Thrown when something is null when it shouldn’t be, mongoc has an internal error, can’t understand server response
      • Should generally be indicative of a bug, either in Swift, c driver, or mongod

      connectionError(message)

      • Any connection related failures (MONGOC_ERROR_STREAM domain)

      authenticationError(message)

      • Any auth related failures (MONGOC_ERROR_CLIENT_AUTHENTICATE)

      Also, define a function that will return an appropriate error given a libmongoc error code and domain.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: