net_error.ts

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

Making or matching an error reaches no network, 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_net_error
#

net_error.ts view source

(error: unknown, kind?: "not_granted" | undefined): error is NetError import {is_net_error} from '@fuzdev/gro/net_error.js';

Whether error is a NetError from any copy of Gro, optionally of one kind.

error

any thrown value

type unknown

kind?

when given, the kind the error must have

type "not_granted"
optional

returns

boolean

NetError
#

net_error.ts view source

import {NetError} from '@fuzdev/gro/net_error.js';

The error net.ts throws when a request is refused before it's sent, typed by kind. Its message is exactly kind: target, and why the module refused is its cause, an Error holding its explanation. Match it with is_net_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 "not_granted"

readonly

target

What was refused: a host as hostname:port, or a scheme like data:. Never the whole URL, which can carry a token.

type string

readonly

constructor

type new (kind: "not_granted", target: string, options?: ErrorOptions | undefined): NetError

kind

type "not_granted"

target

type string

options?

type ErrorOptions
optional

NetErrorKind
#

net_error.ts view source

"not_granted" import type {NetErrorKind} from '@fuzdev/gro/net_error.js';

Why a request was refused. not_granted is a host outside what the handle allows, or a scheme other than http: and https:, on the first request or a redirect. A failure of the network itself is a TypeError, as from any fetch.

Imported by
#