From 3bb6d92be7f421c545d07e59f14a9753b2492ce9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 16 Dec 2017 00:19:20 +0000 Subject: [PATCH] Add very basic error handling. --- src/SyncGate.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/SyncGate.tsx b/src/SyncGate.tsx index da36105..e674eab 100644 --- a/src/SyncGate.tsx +++ b/src/SyncGate.tsx @@ -107,8 +107,28 @@ class SyncGate extends React.PureComponent { const entryArrays = this.props.entries; const journals = this.props.journals.value; + if (this.props.journals.error) { + return this.props.journals.error.toString(); + } else { + let errors: Array<{journal: string, error: Error}> = []; + this.props.entries.forEach((entry, journal) => { + if (entry.error) { + errors.push({journal, error: entry.error}); + } + }); + + if (errors.length > 0) { + return ( + + ); + } + } + if ((journals === null) || - (entryArrays.size === 0) || !entryArrays.every((x: any) => (x.value !== null))) { + (entryArrays.size === 0) || + !entryArrays.every((x: any) => (x.value !== null))) { return (); }