UNPKG

@botpress/webchat-client

Version:
17 lines (13 loc) 422 B
import { IntegrationError } from './types' export async function throwErrorInterceptor(response: Response) { const clonedResponse = response.clone() const data = await clonedResponse.json() if (data?.id?.startsWith('err_')) { const error = new Error(data.message) as Error & IntegrationError error.id = data.id error.code = data.code error.type = data.type throw error } return response }