/** * @file Errno-style error helpers shared by every {@link TinyFSCore} backend. * * These helpers are intentionally dependency free so they can be imported from * the abstract class, from concrete backends and from user code without * creating circular imports. */ export type FileSystemErrorProperties = { /** * POSIX error code, e.g. `ENOENT`. */ code: string; /** * Alias of `code`, mirrors Node.js. */ errno: string; /** * Name of the originating operation. */ syscall: string; /** * Path the operation was applied to. */ path: string; }; export type FileSystemError = Error & FileSystemErrorProperties; /** * @typedef {Object} FileSystemErrorProperties * @property {string} code POSIX error code, e.g. `ENOENT`. * @property {string} errno Alias of `code`, mirrors Node.js. * @property {string} syscall Name of the originating operation. * @property {string} path Path the operation was applied to. */ /** * @typedef {Error & FileSystemErrorProperties} FileSystemError */ /** * Builds an errno-style error that matches the shape produced by Node.js. * * @param {string} code POSIX error code, e.g. `ENOENT`. * @param {string} syscall Name of the originating operation. * @param {string} targetPath Path the operation was applied to. * @param {string} [detail] Extra human readable context. * @returns {FileSystemError} The formatted error. */ export declare const createFileSystemError: (code: string, syscall: string, targetPath: string, detail?: string) => FileSystemError; /** * Translates a `DOMException` thrown by a Web API into an errno-style error. * * @param {unknown} error The value caught from a browser call. * @param {string} syscall Name of the originating operation. * @param {string} targetPath Path the operation was applied to. * @param {string} [mismatchCode] Error code used when the entry exists with the wrong type. * @returns {FileSystemError | Error} An errno-style error. */ export declare const toFileSystemError: (error: unknown, syscall: string, targetPath: string, mismatchCode?: string) => FileSystemError | Error; /** * Validates that a value is a usable path string. * * @param {unknown} value Candidate value. * @param {string} argumentName Name used in the thrown message. * @returns {string} The validated path. * @throws {TypeError} When the value is not a string or contains a null byte. * @throws {Error} When the value is empty. */ export declare const assertPath: (value: unknown, argumentName: string) => string; /** * Validates that a value is a plain options object. * * @param {unknown} value Candidate value. * @param {string} functionName Name used in the thrown message. * @returns {Record} The validated options object. * @throws {TypeError} When the value is not a plain object. */ export declare const assertOptionsObject: (value: unknown, functionName: string) => Record; /** * Validates an encoding identifier. * * @param {unknown} value Candidate encoding. * @param {string} functionName Name used in the thrown message. * @returns {string | null} The validated encoding, or `null` for binary mode. * @throws {TypeError} When the encoding is not supported. */ export declare const assertEncoding: (value: unknown, functionName: string) => string | null; /** * Validates a POSIX permission bitmask. * * @param {unknown} value Candidate mode. * @param {string} argumentName Name used in the thrown message. * @returns {number} The validated mode. * @throws {TypeError} When the value is not an integer. * @throws {RangeError} When the value is outside the 12-bit range. */ export declare const assertMode: (value: unknown, argumentName: string) => number; /** * Validates a non-negative integer. * * @param {unknown} value Candidate value. * @param {string} argumentName Name used in the thrown message. * @returns {number} The validated integer. * @throws {TypeError} When the value is not an integer. * @throws {RangeError} When the value is negative. */ export declare const assertInteger: (value: unknown, argumentName: string) => number; //# sourceMappingURL=error.d.mts.map