UNPKG

@loom-io/core

Version:

A file system wrapper for Node.js and Bun

34 lines (33 loc) 1.16 kB
export function isInstanceOfLoomException(err, ref) { return (err != null && typeof err === "object" && !Array.isArray(err) && "__loomExceptionRef" in err && err.__loomExceptionRef === ref); } export var EXCEPTION_REF; (function (EXCEPTION_REF) { EXCEPTION_REF[EXCEPTION_REF["PLUGIN_NOT_FOUND"] = 0] = "PLUGIN_NOT_FOUND"; EXCEPTION_REF[EXCEPTION_REF["PATH_NOT_EXISTS"] = 1] = "PATH_NOT_EXISTS"; EXCEPTION_REF[EXCEPTION_REF["NO_SOURCE_ADAPTER"] = 2] = "NO_SOURCE_ADAPTER"; EXCEPTION_REF[EXCEPTION_REF["DIRECTORY_NOT_EMPTY"] = 3] = "DIRECTORY_NOT_EMPTY"; })(EXCEPTION_REF || (EXCEPTION_REF = {})); export class PathNotFoundException extends Error { _path; __loomExceptionRef = EXCEPTION_REF.PATH_NOT_EXISTS; constructor(_path) { super(`Path ${_path} does not exist`); this._path = _path; } get path() { return this._path; } } export class DirectoryNotEmptyException extends Error { __loomExceptionRef = EXCEPTION_REF.DIRECTORY_NOT_EMPTY; _path; constructor(path) { super(`Directory ${path} is not empty`); this._path = path; } }