# code-snippets/4.0.0-beta.2/js/entries/feedback-capture.ts

Code Snippets, version 4.0.0-beta.2. 25 lines.

- Page: https://pluginprobe.com/plugins/code-snippets/4.0.0-beta.2/code/js/entries/feedback-capture.ts
- Raw: https://pluginprobe.com/plugins/code-snippets/4.0.0-beta.2/raw/js/entries/feedback-capture.ts
- Modified: 2026-09-22T07:44:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-snippets/4.0.0-beta.2/code/js/entries/feedback-capture.ts#L10-L20`.

```typescript
const MAX_ERRORS = 24

window.codeSnippetsErrors = window.codeSnippetsErrors ?? []

const record = (entry: string): void => {
	if (window.codeSnippetsErrors && window.codeSnippetsErrors.length < MAX_ERRORS) {
		window.codeSnippetsErrors.push(entry)
	}
}

// Capture phase also delivers failed resource loads, as bare Events carrying none of the
// detail below. Recording those would fill the buffer with entries naming nothing.
window.addEventListener('error', event => {
	if (event instanceof ErrorEvent) {
		record(`${event.message || 'Error'} — ${event.filename || 'unknown'}:${event.lineno}`)
	}
}, true)

window.addEventListener('unhandledrejection', event => {
	const reason: unknown = event.reason
	record(`Unhandled rejection — ${reason instanceof Error ? reason.message : String(reason)}`)
})

export {}

```
