For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/genui/openui/core/classes/ToolNotFoundError.md.
Lynx
  • 简体中文
  • 类: ToolNotFoundError

    在函数映射形式的 ToolProvider 中找不到工具名称时抛出的标准错误。Renderer 在内联规范化时用它给出清晰的错误信息。

    继承

    • Error

    构造函数

    构造函数

    new ToolNotFoundError(toolName: string, availableTools?: string[]): ToolNotFoundError

    参数

    参数类型
    toolNamestring
    availableTools?string[]

    返回

    ToolNotFoundError

    重写了

    Error.constructor

    属性

    availableTools

    readonly availableTools: string[]


    cause?

    optional cause?: unknown

    继承自

    Error.cause


    message

    message: string

    继承自

    Error.message


    name

    name: string

    继承自

    Error.name


    stack?

    optional stack?: string

    继承自

    Error.stack


    toolName

    readonly toolName: string


    stackTraceLimit

    static stackTraceLimit: number

    Error.stackTraceLimit 属性指定堆栈跟踪收集的栈帧数量(无论是通过 new Error().stack 还是 Error.captureStackTrace(obj) 生成)。

    默认值为 10,可以设置为任意有效的 JavaScript 数字。修改后只影响之后捕获的堆栈跟踪。

    如果设置为非数字或负数,堆栈跟踪将不会捕获任何栈帧。

    继承自

    Error.stackTraceLimit

    方法

    captureStackTrace()

    static captureStackTrace(targetObject: object, constructorOpt?: Function): void

    在 targetObject 上创建 .stack 属性,访问时返回一个字符串,表示调用 Error.captureStackTrace() 时所在的代码位置。

    const myObject = {};
    Error.captureStackTrace(myObject);
    myObject.stack;  // Similar to `new Error().stack`

    堆栈跟踪的第一行会以 ${myObject.name}: ${myObject.message} 作为前缀。

    可选参数 constructorOpt 接受一个函数。如果传入,生成的堆栈跟踪会省略 constructorOpt 及其之上的所有栈帧。

    constructorOpt 参数可以向用户隐藏生成错误的实现细节。例如:

    function a() {
      b();
    }
    
    function b() {
      c();
    }
    
    function c() {
      // Create an error without stack trace to avoid calculating the stack trace twice.
      const { stackTraceLimit } = Error;
      Error.stackTraceLimit = 0;
      const error = new Error();
      Error.stackTraceLimit = stackTraceLimit;
    
      // Capture the stack trace above function b
      Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
      throw error;
    }
    
    a();

    参数

    参数类型
    targetObjectobject
    constructorOpt?Function

    返回

    void

    继承自

    Error.captureStackTrace


    isError()

    static isError(error: unknown): error is Error

    判断传入的参数是否为内置的 Error 实例。

    参数

    参数类型
    errorunknown

    返回

    error is Error

    继承自

    Error.isError


    prepareStackTrace()

    static prepareStackTrace(err: Error, stackTraces: CallSite[]): any

    参数

    参数类型
    errError
    stackTracesCallSite[]

    返回

    any

    参阅

    https://v8.dev/docs/stack-trace-api#customizing-stack-traces

    继承自

    Error.prepareStackTrace

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。