Options
All
  • Public
  • Public/Protected
  • All
Menu

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继承层级

Index索引

Constructors构造函数

Properties属性

cause?: Error
code?: string | number

This is a number in MongoServerError and a string in MongoDriverError这是MongoServerError中的数字和MongoDriverError的字符串

privateremarks

Define the type override on the subclasses when we can use the override keyword当我们可以使用override关键字时,在子类上定义类型重写

connectionGeneration?: number
message: string
stack?: string
topologyVersion?: TopologyVersion
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => 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方法

  • addErrorLabel(label: string): void
  • hasErrorLabel(label: string): boolean
  • 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

  • captureStackTrace(targetObject: object, constructorOpt?: Function): void
  • Create .stack property on a target object在目标对象上创建.stack属性

    Parameters参数

    • targetObject: object
    • Optional constructorOpt: Function

    Returns 返回 void

Generated using TypeDoc