fs_error.ts

The errors of the fs host module (fs.ts), apart from it.

Making or matching an error reaches no filesystem, so this module grants nothing: code that only classifies a failure, or builds one, imports it without linking the host module, and a mock of the host module throws the same errors it does. The class and its prototype are frozen.

view source

Declarations
#

4 declarations

FsError
#

fs_error.ts view source

import {FsError} from '@fuzdev/gro/fs_error.js';

The error every fs op throws, typed by kind. Its message is exactly kind: path, and what the OS or the module said of the failure, when there is more to say, is its cause. Match it with is_fs_error, which also recognizes one from another copy of Gro. The class and its prototype are frozen.

inheritance

extends: Error

name

type string

kind

type FsErrorKind

readonly

path

The absolute path the op targeted, or for outside_root the path as requested.

type string

readonly

constructor

type new (kind: FsErrorKind, path: string, options?: ErrorOptions | undefined): FsError

kind

path

type string

options?

type ErrorOptions
optional

FsErrorKind
#

fs_error.ts view source

FsErrorKind

type "not_found" | "already_exists" | "permission_denied" | "not_a_directory" | "is_a_directory" | "not_empty" | "outside_root" | "not_granted" | "io_error"

import type {FsErrorKind} from '@fuzdev/gro/fs_error.js';

Why an fs op failed. outside_root is a path that would leave its handle; not_granted is a reach outside what the run granted, refused whether or not anything is there, which only the runtime's builtin module throws, since the Node module checks no grant; io_error is every failure without a kind of its own.

is_fs_error
#

fs_error.ts view source

(error: unknown, kind?: FsErrorKind | undefined): error is FsError import {is_fs_error} from '@fuzdev/gro/fs_error.js';

Whether error is an FsError from any copy of Gro, optionally of one kind.

error

any thrown value

type unknown

kind?

when given, the kind the error must have

optional

returns

boolean

is_own_fs_error
#

fs_error.ts view source

internal

(value: unknown): value is FsError import {is_own_fs_error} from '@fuzdev/gro/fs_error.js';

Whether value is an FsError made by this copy of the module, by its private brand, so classifying an error mid-op runs no caller's code, as instanceof would through a Symbol.hasInstance or a proxy's getPrototypeOf. For the host module's own ops; other code matches errors with is_fs_error.

value

any value

type unknown

returns

boolean

Imported by
#