I seem to be unable to catch exceptions from response.json()
page.on('response', async res => {
if (res.request().resourceType() == 'xhr') {
if (res.url() == search_prefix) {
console.log(res.status(),res.url())
try {
const data = await res.json()
if (data != undefined && data.status == "success") {
results = parseResults(data,config)
}
}
catch (error) {}
}
}
})
I only have one place in my code where I am parsing json from a response. I have a webpage that sometimes gives invalid JSON data. I am expecting the above code to catch the json exception and continue executing. However, the exception is caught in my "uncaught" exception handling.