PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / entries / feedback-capture.ts

feedback-capture.ts in Code Snippets 4.0.0-beta.2, at js/entries/feedback-capture.ts

25 lines 818 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const MAX_ERRORS = 24
2
3 window.codeSnippetsErrors = window.codeSnippetsErrors ?? []
4
5 const record = (entry: string): void => {
6 if (window.codeSnippetsErrors && window.codeSnippetsErrors.length < MAX_ERRORS) {
7 window.codeSnippetsErrors.push(entry)
8 }
9 }
10
11 // Capture phase also delivers failed resource loads, as bare Events carrying none of the
12 // detail below. Recording those would fill the buffer with entries naming nothing.
13 window.addEventListener('error', event => {
14 if (event instanceof ErrorEvent) {
15 record(`${event.message || 'Error'}${event.filename || 'unknown'}:${event.lineno}`)
16 }
17 }, true)
18
19 window.addEventListener('unhandledrejection', event => {
20 const reason: unknown = event.reason
21 record(`Unhandled rejection — ${reason instanceof Error ? reason.message : String(reason)}`)
22 })
23
24 export {}
25