From 47468fca681219ee57f6b60cf4ba09e262c042ee Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 30 Nov 2018 16:09:56 +0100 Subject: [PATCH] Explore: Show logging errors from backend - Logging datasource sends error string directly in the message body - allowing response body to be an error when query transaction failed - added throw in case we ever encounter unhandled errors again (forces us to fix the issue) --- public/app/features/explore/Explore.tsx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index 5926ee59612..019cdef3353 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -727,14 +727,20 @@ export class Explore extends React.PureComponent { let error: string | JSX.Element = response; if (response.data) { - error = response.data.error; - if (response.data.response) { - error = ( - <> - {response.data.error} -
{response.data.response}
- - ); + if (typeof response.data === 'string') { + error = response.data; + } else if (response.data.error) { + error = response.data.error; + if (response.data.response) { + error = ( + <> + {response.data.error} +
{response.data.response}
+ + ); + } + } else { + throw new Error('Could not handle error response'); } }