Surface error when the bgscript can't reach the tab (#443)

This commit is contained in:
Andre Natal 2022-07-12 18:03:40 -07:00 коммит произвёл GitHub
Родитель dc520dd839
Коммит f04f8b8869
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 21 добавлений и 15 удалений

Просмотреть файл

@ -324,20 +324,26 @@ const messageListener = function(message, sender) {
break;
case "translationRequested":
translationRequestsByTab.set(message.tabId, message);
// requested for translation received. let's inform the mediator
browser.tabs.sendMessage(
message.tabId,
{
command: "translationRequested",
tabId: message.tabId,
from: message.from,
to: message.to,
withOutboundTranslation: message.withOutboundTranslation,
withQualityEstimation: message.withQualityEstimation
}
);
break;
translationRequestsByTab.set(message.tabId, message);
// requested for translation received. let's inform the mediator
browser.tabs.sendMessage(
message.tabId,
{
command: "translationRequested",
tabId: message.tabId,
from: message.from,
to: message.to,
withOutboundTranslation: message.withOutboundTranslation,
withQualityEstimation: message.withQualityEstimation
}
).catch(error => {
// eslint-disable-next-line no-use-before-define
sendUpdateProgress(message.tabId, ["updateProgress", "errorLoadingWasm"]);
getTelemetry(message.tabId).record("counter", "errors", "translation");
console.warn("Reporting error to Sentry");
Sentry.captureException(error);
});
break;
case "downloadLanguageModels":
try {
// eslint-disable-next-line no-use-before-define
@ -356,7 +362,7 @@ const messageListener = function(message, sender) {
// eslint-disable-next-line no-use-before-define
sendUpdateProgress(message.tabId, ["updateProgress", "errorLoadingWasm"]);
getTelemetry(message.tabId).record("counter", "errors", "model_load");
console.warn("Reporting content script error to Sentry");
console.warn("Reporting error to Sentry");
Sentry.captureException(error);
}
break;