/** * Human-readable text instead of a system message with paths inside: these * strings are shown on the «Данные» screen, while the full error with the path * goes to the server log only. * * Single source on purpose: the same description used to live in two files and * the lists had already drifted - ENOENT was known only to one copy, EISDIR and * EMFILE only to the other, so the same failure was named differently depending * on where it happened. */ export function describeError(error) { const code = error?.code ?? ''; if (code === 'ENOENT') return 'файл или каталог не найдены'; if (code === 'EACCES' || code === 'EPERM') return 'нет прав доступа к файлу'; if (code === 'EBUSY') return 'файл занят другой программой'; if (code === 'EISDIR') return 'по этому имени лежит папка, а не файл'; if (code === 'ETIMEDOUT' || code === 'EIO' || code === 'EHOSTDOWN' || code === 'ENOTCONN') { return 'каталог с данными недоступен'; } if (code === 'EMFILE' || code === 'ENFILE') return 'слишком много открытых файлов'; return `не удалось прочитать файл${code ? ` (код ${code})` : ''}`; }