From 4052a5386d7d92728f2006b0909708e209467840 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 8 Mar 2020 19:17:40 -0400 Subject: [PATCH] Catch errors in rendering values. --- src/FormView.css | 5 +++++ src/FormView.tsx | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/FormView.css b/src/FormView.css index 905e612..c63a2e5 100644 --- a/src/FormView.css +++ b/src/FormView.css @@ -36,3 +36,8 @@ text-align: right; padding: 0 5px; } + +.error { + color: red; + font-weight: bold; +} diff --git a/src/FormView.tsx b/src/FormView.tsx index 9205bb3..ab0cf6f 100644 --- a/src/FormView.tsx +++ b/src/FormView.tsx @@ -27,11 +27,18 @@ export default function FormView(props: FormProps) { function Line(props: { tr, line }) { const { tr, line } = props; + const value = createMemo(() => { + try { + return line.value(tr); + } catch (e) { + return {e.message}; + } + }); return ( {line.id} {line.description} - {line.value(tr)} + {value()} ); } -- 2.43.5