Skip to content

Commit dd374c0

Browse files
committed
Check if response is not JSON, throw error, for #367
1 parent a765902 commit dd374c0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mink-plugin/mink.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,15 @@ async function fetchTimeMap (uri, tabid) {
326326
setTimemapInStorage(data, data.original)
327327
})
328328
.catch(function(err) {
329-
console.log(`Error fetching {uri}`)
329+
console.log(`Error fetching ${uri}`)
330330
console.log(err.message)
331331

332332
if (err.name === 'ZeroMementos') {
333333
showInterfaceForZeroMementos(tabid)
334334
} else if (err.name === 'InaccessibleAggregator') {
335-
log('TODO: swtich up the aggregator')
335+
log('TODO: switch up the aggregator')
336+
} else if (err instanceof SyntaxError) {
337+
log("JSON parsing failed, switch up the aggregator")
336338
}
337339
})
338340
/*
@@ -521,6 +523,7 @@ chrome.webRequest.onHeadersReceived.addListener(function (deets) {
521523
if (cachedTMKeys.length > 10) { // Keep the cache to a reasonable size through random deletion
522524
log('******* Number of cached URL Headers:')
523525
const indexToRemove = Math.floor(Math.random() * cachedTMKeys.length)
526+
console.log('foo')
524527
const keyOfIndex = cachedTMKeys[indexToRemove]
525528
delete data[keyOfIndex]
526529
}

0 commit comments

Comments
 (0)