forked from mirrors/thatmattlove-hyperglass
improve UI error output
This commit is contained in:
parent
3886925501
commit
1d0592a1cd
3 changed files with 15 additions and 6 deletions
|
|
@ -26,5 +26,9 @@ export const FormattedError: React.FC<TFormattedError> = (props: TFormattedError
|
|||
const { keywords, message } = props;
|
||||
const pattern = new RegExp(keywords.map(kw => `(${kw})`).join('|'), 'gi');
|
||||
const things = formatError(message, keywords, pattern);
|
||||
return <Text as="span">{keywords.length !== 0 ? things : message}</Text>;
|
||||
return (
|
||||
<Text as="span" fontWeight={keywords.length === 0 ? 'bold' : undefined}>
|
||||
{keywords.length !== 0 ? things : message}
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -164,7 +164,8 @@ const _Result: React.ForwardRefRenderFunction<HTMLDivElement, TResult> = (props:
|
|||
<AccordionHeaderWrapper>
|
||||
<AccordionButton py={2} w="unset" _hover={{}} _focus={{}} flex="1 0 auto">
|
||||
<ResultHeader
|
||||
isError={isLGOutputOrError(data)}
|
||||
// isError={isLGOutputOrError(data)}
|
||||
isError={isError}
|
||||
loading={isLoading}
|
||||
errorMsg={errorMsg}
|
||||
errorLevel={errorLevel}
|
||||
|
|
@ -208,17 +209,17 @@ const _Result: React.ForwardRefRenderFunction<HTMLDivElement, TResult> = (props:
|
|||
) : isStringOutput(data) && data.level === 'success' && !tableComponent ? (
|
||||
<TextOutput>{data.output}</TextOutput>
|
||||
) : isStringOutput(data) && data.level !== 'success' ? (
|
||||
<Alert rounded="lg" my={2} py={4} status={errorLevel}>
|
||||
<Alert rounded="lg" my={2} py={4} status={errorLevel} variant="solid">
|
||||
<FormattedError message={data.output} keywords={errorKeywords} />
|
||||
</Alert>
|
||||
) : (
|
||||
<Alert rounded="lg" my={2} py={4} status={errorLevel}>
|
||||
<Alert rounded="lg" my={2} py={4} status={errorLevel} variant="solid">
|
||||
<FormattedError message={errorMsg} keywords={errorKeywords} />
|
||||
</Alert>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Alert rounded="lg" my={2} py={4} status={errorLevel}>
|
||||
<Alert rounded="lg" my={2} py={4} status={errorLevel} variant="solid">
|
||||
<FormattedError message={errorMsg} keywords={errorKeywords} />
|
||||
</Alert>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,11 @@ export function useLGQuery(query: TFormQuery): QueryObserverResult<TQueryRespons
|
|||
request_timeout * 1000,
|
||||
controller,
|
||||
);
|
||||
return await res.json();
|
||||
try {
|
||||
return await res.json();
|
||||
} catch (err) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel any still-running queries on unmount.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue