spawn_error.ts

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

Making or matching an error starts no process, 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
#

3 declarations

is_spawn_error
#

spawn_error.ts view source

(error: unknown, kind?: SpawnErrorKind | undefined): error is SpawnError import {is_spawn_error} from '@fuzdev/gro/spawn_error.js';

Whether error is a SpawnError 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

SpawnError
#

spawn_error.ts view source

import {SpawnError} from '@fuzdev/gro/spawn_error.js';

The error spawn.ts throws when a program can't be reached or started, typed by kind. A program that started and exited non-zero is a result, not this error. Its message is exactly kind: program, and what the OS or the module said of the failure, when there is more to say, is its cause. Match it with is_spawn_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 SpawnErrorKind

readonly

program

The program's name as it was requested.

type string

readonly

constructor

type new (kind: SpawnErrorKind, program: string, options?: ErrorOptions | undefined): SpawnError

kind

program

type string

options?

type ErrorOptions
optional

SpawnErrorKind
#

spawn_error.ts view source

SpawnErrorKind

type "not_found" | "not_executable" | "not_granted" | "launch_failed"

import type {SpawnErrorKind} from '@fuzdev/gro/spawn_error.js';

Why a program couldn't be reached or started. not_found is a name that resolves to no regular executable; not_executable is a regular file without execute permission, or one the module refuses (.bat, .cmd, a format that's neither #! nor ELF); not_granted is a name outside what the handle allows, or an environment a narrowed root can't give; launch_failed is a pinned program that couldn't start, its cause saying which and why, and that cause's own cause what stopped it: Node's error, the call's signal's reason when it had already aborted, or the stat's error when a #! script's found path no longer resolves; a #! script whose found path now leads to another file has the explanation alone.

Imported by
#