Class MongoUnexpectedServerResponseError

An error generated when a parsable unexpected response comes from the server.服务器发出可解析的意外响应时生成的错误。 This is generally an error where the driver in a state expecting a certain behavior to occur in the next message from MongoDB but it receives something else.这通常是一个错误,驱动程序处于期望某个行为在来自MongoDB的下一条消息中发生的状态,但它收到了其他东西。 This error does not represent an issue with wire message formatting.此错误并不表示电报格式有问题。

Example

When an operation fails, it is the driver's job to retry it. 当操作失败时,驱动程序的工作是重试。It must perform serverSelection again to make sure that it attempts the operation against a server in a good state. 它必须再次执行serverSelection,以确保尝试对处于良好状态的服务器执行操作。If server selection returns a server that does not support retryable operations, this error is used.如果服务器选择返回的服务器不支持可重试操作,则使用此错误。This scenario is unlikely as retryable support would also have been determined on the first attempt but it is possible the state change could report a selectable server that does not support retries.这种情况不太可能发生,因为在第一次尝试时也会确定可重试支持,但状态更改可能会报告不支持重试的可选服务器。

Hierarchy

Constructors

  • Do not use this constructor!不要使用此构造函数!

    Meant for internal use only.仅供内部使用。

    Parameters

    • message: string

    Returns MongoUnexpectedServerResponseError

    Remarks

    This class is only meant to be constructed within the driver. 这个类只能在驱动程序中构造。This constructor is not subject to semantic versioning compatibility guarantees and may change at any time.此构造函数不受语义版本控制兼容性保证的约束,并且可能随时更改。

Properties

cause?: Error
code?: string | number

This is a number in MongoServerError and a string in MongoDriverError这是MongoServerError中的一个数字,也是MongoDriverError中的字符串

connectionGeneration?: number
message: string
stack?: string
topologyVersion?: TopologyVersion
prepareStackTrace?: ((err, stackTraces) => any)

Type declaration

stackTraceLimit: number

Accessors

  • get errmsg(): string
  • Legacy name for server error responses服务器错误响应的旧名称

    Returns string

  • get errorLabels(): string[]
  • Returns string[]

  • get name(): string
  • Returns string

Methods

  • Checks the error to see if it has an error label检查错误以查看它是否有错误标签

    Parameters

    • label: string

      The error label to check for要检查的错误标签

    Returns boolean

    returns true if the error has the provided error label如果错误具有提供的错误标签,则返回true

  • Create .stack property on a target object在目标对象上创建.stack属性

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void

Generated using TypeDoc