( toolName: string | undefined, toolResult: unknown )
| 247 | } |
| 248 | |
| 249 | export function toRenderOnlyToolErrorBlock( |
| 250 | toolName: string | undefined, |
| 251 | toolResult: unknown |
| 252 | ): RenderOnlyToolErrorBlock | null { |
| 253 | if (!isRenderOnlyTool(toolName)) return null |
| 254 | if (extractChartPayloads(toolResult).length > 0) return null |
| 255 | |
| 256 | const text = extractToolResultText(toolResult) |
| 257 | if (!text) return null |
| 258 | |
| 259 | const match = /^Error:\s*(.+)$/is.exec(text) |
| 260 | const message = match?.[1]?.trim() |
| 261 | if (!message) return null |
| 262 | if (/^Call get_schema before render_chart\b/i.test(message)) return null |
| 263 | |
| 264 | return { |
| 265 | type: 'error', |
| 266 | error: { |
| 267 | name: 'ChartRenderError', |
| 268 | message, |
| 269 | stack: null, |
| 270 | }, |
| 271 | } |
| 272 | } |
no test coverage detected