From 9e03be9890049250e174cbb7e0c89c27ce39e41f Mon Sep 17 00:00:00 2001 From: Ernst Widerberg Date: Thu, 25 Nov 2021 09:20:19 +0100 Subject: Fix error handling: Throw only Error objects --- src/components/ObjectView.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/components/ObjectView.js') diff --git a/src/components/ObjectView.js b/src/components/ObjectView.js index cecadeb..72c7e5c 100644 --- a/src/components/ObjectView.js +++ b/src/components/ObjectView.js @@ -25,7 +25,9 @@ class ObjectView extends React.Component { // TODO: Look at `status` or return code or both? .then(resp => { if (resp.status !== 200) - throw `Unexpected HTTP response code from soc_collector: ${resp.status} ${resp.statusText}`; + throw new Error( + `Unexpected HTTP response code from soc_collector: ${resp.status} ${resp.statusText}` + ); this.setState({ totalPages: resp.headers.get("X-Total-Count") }); @@ -33,7 +35,9 @@ class ObjectView extends React.Component { }) .then(json => { if (json.status != "success") - throw `Unexpected status from soc_collector: ${json.status}`; + throw new Error( + `Unexpected status from soc_collector: ${json.status}` + ); this.setState({ object: json.docs }); -- cgit v1.1