2
0

🚸 (js) Display last input if send message errored

This commit is contained in:
Baptiste Arnaud
2023-04-03 18:14:32 +02:00
parent a5d3f83c7f
commit 9f8398b9ae
7 changed files with 38 additions and 18 deletions

View File

@ -60,11 +60,17 @@ export const Bot = (props: BotProps & { class?: string }) => {
},
})
if (error && 'code' in error && typeof error.code === 'string') {
if (typeof props.typebot !== 'string' || (props.isPreview ?? false)) {
setError(
new Error('An error occurred while loading the bot.', {
cause: error.message,
})
)
}
if (['BAD_REQUEST', 'FORBIDDEN'].includes(error.code))
setError(new Error('This bot is now closed.'))
if (error.code === 'NOT_FOUND')
setError(new Error("The bot you're looking for doesn't exist."))
return
}
if (!data) return setError(new Error("Error! Couldn't initiate the chat."))