2
0

🐛 Fix error display on preview start

This commit is contained in:
Baptiste Arnaud
2023-04-05 21:10:57 +02:00
parent f18889a046
commit 3196fe3759
3 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.32",
"version": "0.0.33",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",

View File

@ -61,16 +61,16 @@ 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(
return 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.'))
return 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 setError(new Error("The bot you're looking for doesn't exist."))
}
if (!data) return setError(new Error("Error! Couldn't initiate the chat."))

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.32",
"version": "0.0.33",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",