diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-01-28 15:18:15 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-01-28 15:18:15 +0100 |
commit | ea9df6c7688613783ca114f0f11c6f6baf30036b (patch) | |
tree | b3ed1a2bdfcd313a992ac4d7618b2a860949dbe3 /html | |
parent | fbfddb02afc6f144b1255b677e0d4249adc10b89 (diff) | |
download | browser-extension-ea9df6c7688613783ca114f0f11c6f6baf30036b.tar.gz browser-extension-ea9df6c7688613783ca114f0f11c6f6baf30036b.zip |
update error reporting in popup
Diffstat (limited to 'html')
-rw-r--r-- | html/popup.js | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/html/popup.js b/html/popup.js index b4602f3..532feba 100644 --- a/html/popup.js +++ b/html/popup.js @@ -79,18 +79,40 @@ function show_page_info(page_info) { by_id("scripts_blocked").innerText = page_info.allow ? "no" : "yes"; - by_id("injected_payload").innerText = page_info.payload ? - page_info.payload.identifier : "None"; + let payload_text = "None"; + + if (page_info.payload) { + if ("error" in page_info) { + if (page_info.error.haketilo_error_type === "missing") + payload_text = `None (error: resource with id '${page_info.error.id}' missing from the database)`; + else if (page_info.error.haketilo_error_type === "circular") + payload_text = `None (error: circular dependency of resource with id '${page_info.error.id}' on itself)`; + else if (page_info.error.haketilo_error_type === "db") + payload_text = `None (error: failure reading Haketilo internal database)`; + else if (page_info.error.haketilo_error_type === "other") + payload_text = `None (error: unknown failure occured)`; + } else { + payload_text = page_info.payload.identifier; + } + } + + by_id("injected_payload").innerText = payload_text; const scripts_fate = page_info.allow ? "allowed" : "blocked"; + let mapping_text; + if (page_info.mapping === "~allow") - var mapping = `None (scripts ${scripts_fate} by a rule)`; + mapping_text = `None (scripts ${scripts_fate} by a rule)`; + else if ("error" in page_info + && page_info.error.haketilo_error_type ==="deciding_policy") + mapping_text = `None (error occured when determining policy)`; else if (page_info.mapping) - var mapping = page_info.mapping; - else if (page_info.error) - var mapping = `None (error occured when determining policy)`; - by_id("mapping_used").innerText = mapping; + mapping_text = page_info.mapping; + else + mapping_text = `None (scripts ${scripts_fate} by default policy)`; + + by_id("mapping_used").innerText = mapping_text; } } |