# Function extractToolName

- extractToolName(error: unknown, fallback: string): string

  Extracts the nearest `toolName` from an error's cause chain.

  Walks the chain from the provided error toward its causes, returning the first `ToolError` encountered (that is, the outermost `ToolError` in the chain). Falls back to the provided `fallback` when no `ToolError` is found.

  #### Parameters

  - error: unknown

    Root error to inspect

  - fallback: string

    Default tool name when no `ToolError` is in the chain

  #### Returns string

  The resolved tool name

  - Defined in tools/shared/errorHandler.ts:88