fix: wrap parsing with try catch (#1321)

This commit is contained in:
Mamadou DICKO 2023-10-04 11:26:25 +02:00 committed by GitHub
parent a8f9edb21f
commit bf5b7553d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,9 +20,19 @@ export const NotificationDisplayer = ({
return <Fragment />;
}
const { message, status, name } = JSON.parse(
nonParsedMessage.replace(/'/g, '"')
) as NotificationMessage;
let message, status, name;
try {
const parsedMessage = JSON.parse(
nonParsedMessage.replace(/'/g, '"')
) as NotificationMessage;
message = parsedMessage.message;
status = parsedMessage.status;
name = parsedMessage.name;
} catch (error) {
return <Fragment />;
}
return (
<div
@ -42,9 +52,9 @@ export const NotificationDisplayer = ({
</div>
</div>
{isHovered && (
<div
<div
className="absolute bg-white p-2 rounded-sm border border-gray-100 shadow-sm transition-transform transform translate-y-1 translate-x-1/4 z-10"
style={{ bottom: '-10px', right: '10px' }}
style={{ bottom: "-10px", right: "10px" }}
>
{message}
</div>