trypatch()
ts
function trypatch<ResultSchema, ToolContext>(options): LegacyMethodDecorator & Stage3MethodDecorator<ResultSchema>;Method decorator that investigates a failed call (with an AI provider or your own handler) and returns the value it recovers in place of the error, or rejects with the original error when nothing is recovered. The decorated method must return a Promise; TC39 stage-3 and legacy experimentalDecorators both work.
Type Parameters
ResultSchema
ResultSchema extends Schema
ToolContext
ToolContext = unknown
Parameters
options
TrypatchOptions<ResultSchema, ToolContext>
Returns
LegacyMethodDecorator & Stage3MethodDecorator<ResultSchema>