Skip to content

Commit

Permalink
fix: wrap parsing with try catch (QuivrHQ#1321)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko authored Oct 4, 2023
1 parent a8f9edb commit bf5b755
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
Expand Down

0 comments on commit bf5b755

Please sign in to comment.