Skip to content

Commit

Permalink
Add exception handling while decoding the user input
Browse files Browse the repository at this point in the history
  • Loading branch information
harishmohanraj committed Sep 5, 2024
1 parent 3356c4e commit 53aa945
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions app/src/client/app/PlayGroundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,19 @@ const PlayGroundPage = ({ user }: { user: User }) => {
useEffect(() => {
if (formSubmitMsg && currentChatDetails) {
if (!currentChatDetails.userRespondedWithNextAction) {
const decodedMessage = decodeURIComponent(formSubmitMsg);
setTriggerChatFormSubmitMsg(decodedMessage);
try {
const decodedMessage = decodeURIComponent(formSubmitMsg);
setTriggerChatFormSubmitMsg(decodedMessage);
} catch (err: any) {
console.log('Error: ' + err.message);
setNotificationErrorMessage('There was an error processing your message. Please start a new chat.');
updateCurrentChat({
id: activeChatId,
data: {
isChatTerminated: true,
},
});
}
}
removeQueryParameters();
}
Expand Down Expand Up @@ -198,9 +209,11 @@ const PlayGroundPage = ({ user }: { user: User }) => {
/>
</>
) : (
<div className='z-[999999] absolute inset-0 flex items-center justify-center bg-white bg-opacity-50'>
<Loader />
</div>
!currentChatDetails.isChatTerminated && (
<div className='z-[10000] absolute inset-0 flex items-center justify-center bg-white bg-opacity-50'>
<Loader />
</div>
)
)}
</div>
) : (
Expand Down
2 changes: 1 addition & 1 deletion app/src/client/components/NotificationBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const NotificationBox: React.FC<NotificationBoxProps> = ({ type, message, onClic
const isSuccess = type === 'success';

return (
<div className='fixed inset-0 flex items-center justify-center z-50 p-16 backdrop-blur-sm bg-airt-font-base/30'>
<div className='fixed inset-0 flex items-center justify-center z-[10000] p-16 backdrop-blur-sm bg-airt-font-base/30'>
<div className='bg-airt-primary rounded-lg shadow-lg p-8 m-4 max-w-sm mx-auto'>
<h2 className='text-xl font-bold mb-4 text-airt-font-base'>{isSuccess ? 'Success' : 'Error'}</h2>
<p className='text-airt-font-base'>{message}</p>
Expand Down

0 comments on commit 53aa945

Please sign in to comment.