# code-block-pro/1.28.0/src/util/errors.ts

Code Block Pro – Beautiful Syntax Highlighting, version 1.28.0. 46 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.28.0/code/src/util/errors.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.28.0/raw/src/util/errors.ts
- Modified: 2026-04-12T13:22:22+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-block-pro/1.28.0/code/src/util/errors.ts#L10-L20`.

```typescript
import { subscribe } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

export const debounce = <T extends (...args: unknown[]) => void>(
	fn: T,
	delay: number,
) => {
	let timeout: ReturnType<typeof setTimeout> | null = null;
	return (...args: Parameters<T>) => {
		if (timeout) clearTimeout(timeout);
		timeout = setTimeout(() => fn(...args), delay);
	};
};

export const handleValidationErrors = () => {
	const debouncedUnsub = debounce(() => unsub(), 5000);

	const unsub = subscribe(() => {
		const editor = document.querySelector(
			'#editor, iframe[name="editor-canvas"]',
		);
		const blockErrors = editor?.querySelectorAll(
			'.wp-block-kevinbatdorf-code-block-pro .block-editor-warning',
		);
		if (!blockErrors?.length) return;
		blockErrors.forEach((blockError) => {
			const message = blockError.querySelector(
				'.block-editor-warning__message',
			);
			if (message) {
				message.textContent = __(
					'This block has been updated. Press update to refresh.',
					'code-block-pro',
				);
			}
			const button = blockError.querySelector(
				'.block-editor-warning__action button',
			);
			if (button) {
				button.textContent = __('Update', 'code-block-pro');
			}
		});
		debouncedUnsub();
	});
};

```
