2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
const core = globalThis.Deno.core;
|
|
|
|
const { BadResource, Interrupted } = core;
|
|
|
|
const primordials = globalThis.__bootstrap.primordials;
|
|
|
|
const { Error } = primordials;
|
2021-06-28 19:43:03 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class NotFound extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "NotFound";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class PermissionDenied extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "PermissionDenied";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class ConnectionRefused extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "ConnectionRefused";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class ConnectionReset extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "ConnectionReset";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class ConnectionAborted extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "ConnectionAborted";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class NotConnected extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "NotConnected";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class AddrInUse extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "AddrInUse";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class AddrNotAvailable extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "AddrNotAvailable";
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
2023-02-07 14:22:46 -05:00
|
|
|
}
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class BrokenPipe extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "BrokenPipe";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AlreadyExists extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "AlreadyExists";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class InvalidData extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "InvalidData";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TimedOut extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "TimedOut";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class WriteZero extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "WriteZero";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 17:14:33 -05:00
|
|
|
class WouldBlock extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "WouldBlock";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
class UnexpectedEof extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "UnexpectedEof";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Http extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "Http";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Busy extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "Busy";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class NotSupported extends Error {
|
|
|
|
constructor(msg) {
|
|
|
|
super(msg);
|
|
|
|
this.name = "NotSupported";
|
|
|
|
}
|
|
|
|
}
|
2020-08-25 18:22:15 -04:00
|
|
|
|
2023-02-07 14:22:46 -05:00
|
|
|
const errors = {
|
|
|
|
NotFound,
|
|
|
|
PermissionDenied,
|
|
|
|
ConnectionRefused,
|
|
|
|
ConnectionReset,
|
|
|
|
ConnectionAborted,
|
|
|
|
NotConnected,
|
|
|
|
AddrInUse,
|
|
|
|
AddrNotAvailable,
|
|
|
|
BrokenPipe,
|
|
|
|
AlreadyExists,
|
|
|
|
InvalidData,
|
|
|
|
TimedOut,
|
|
|
|
Interrupted,
|
|
|
|
WriteZero,
|
2023-02-12 17:14:33 -05:00
|
|
|
WouldBlock,
|
2023-02-07 14:22:46 -05:00
|
|
|
UnexpectedEof,
|
|
|
|
BadResource,
|
|
|
|
Http,
|
|
|
|
Busy,
|
|
|
|
NotSupported,
|
|
|
|
};
|
|
|
|
|
|
|
|
export { errors };
|