From 16ac6ad5a6f70d93a13258672669f529fb44b425 Mon Sep 17 00:00:00 2001 From: Zizhou Wang Date: Mon, 22 Nov 2021 14:35:27 -0500 Subject: [PATCH] Fix error rendering logic --- .../public/components/SessionView/index.tsx | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/session_view/public/components/SessionView/index.tsx b/x-pack/plugins/session_view/public/components/SessionView/index.tsx index 7bc89f262f474..949a2dc7f0afa 100644 --- a/x-pack/plugins/session_view/public/components/SessionView/index.tsx +++ b/x-pack/plugins/session_view/public/components/SessionView/index.tsx @@ -64,14 +64,16 @@ export const SessionView = ({ sessionEntityId, height }: SessionViewDeps) => { } }; - const { isLoading, data: getData } = useQuery( - ['process-tree', 'process_tree'], - () => - http.get(PROCESS_EVENTS_ROUTE, { - query: { - sessionEntityId, - }, - }) + const { + isLoading, + isError, + data: getData, + } = useQuery(['process-tree', 'process_tree'], () => + http.get(PROCESS_EVENTS_ROUTE, { + query: { + sessionEntityId, + }, + }) ); const sortEvents = (a: ProcessEvent, b: ProcessEvent) => { @@ -118,7 +120,18 @@ export const SessionView = ({ sessionEntityId, height }: SessionViewDeps) => { /> ); - } else if (data) { + } + if (isError) { + return ( + Error loading Session View} + body={

There was an error loading the Session View.

} + /> + ); + } + if (data) { return (
{
); } - return ( - Error loading Session View} - body={

There was an error loading the Session View.

} - /> - ); }; - if (!(isLoading || data.length)) { + if (!(isLoading || isError || data.length)) { return renderNoData(); }