refactor: add error messages i18n

This commit is contained in:
2026-08-25 09:49:15 +05:00
parent c04a1fc1dc
commit 486b99dbb8
27 changed files with 262 additions and 94 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import { createPixelImage, type PixelImage } from './types';
import { ToolError } from './errors';
const MAX_COLOR_DISTANCE = Math.sqrt(3 * 255 * 255);
@@ -120,7 +121,7 @@ export function flattenOntoColor(img: PixelImage, hex: string): PixelImage {
export function parseHex(hex: string): [number, number, number] {
const match = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
if (!match) {
throw new Error(`Некорректный HEX-цвет: "${hex}"`);
throw new ToolError('errors.badHex', { value: hex });
}
const digits = match[1];
if (digits.length === 3) {