import { ErrnoException } from './interfaces.js'; import { code } from './errno.js'; export const exports = {}; Object.keys(code).forEach(function (code) { const e = code[code]; exports[code] = (path) => { const err = new Error(code + ', ' + e.description + (path ? ' \'' + path + '\'' : '')); err.errno = e.errno; err.code = code; err.path = path; return err; }; }); export const ErrNoFileOrDir = (path) => { return new Error('Can\'t remove ' + path + ' The path is not file nor directory'); }; export const ErrCantDelete = (path) => { return new Error('Can\'t remove ' + path); }; export const ErrNotFile = (path) => { return new Error('Path ' + path + ' exists but is not a file.' + ' Halting jetpack.file() call for safety reasons.'); }; export const ErrNoDirectory = (path) => { return new Error('Path ' + path + ' exists but is not a directory.' + ' Halting jetpack.dir() call for safety reasons.'); }; export const ErrDoesntExists = (path) => { const err = new Error('Path to copy doesn\'t exist ' + path); err.code = 'ENOENT'; return err; }; export const ErrDestinationExists = (path) => { const err = new Error('Destination path already exists ' + path); err.code = 'EEXIST'; return err; }; export const ErrIsNotDirectory = (path) => { const err = new ErrnoException('Path you want to find stuff in must be a directory ' + path); err.code = 'ENOTDIR'; return err; };