Skip to content

Commit

Permalink
chore: add a try catch on function wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
iyxan23 committed Sep 21, 2024
1 parent dfcccdb commit 92f819e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sheet/templater-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ export function createTemplaterFunction<T extends z.AnyZodTuple, R>(
);
}

return call(...(result.data as MapFunctionsToLambdas<z.infer<T>>));
try {
return call(...(result.data as MapFunctionsToLambdas<z.infer<T>>));
} catch (e) {
return failure(
{
message: `Error while calling ${functionName}. trace: ${context.callTree.join(
" > ",
)}. Error: ${JSON.stringify(e)}`,
col: context.col,
row: context.row,
},
[],
);
}
};
}

0 comments on commit 92f819e

Please sign in to comment.