Skip to content

Commit

Permalink
Directly export errno values
Browse files Browse the repository at this point in the history
Better for dead code elimination
  • Loading branch information
TooTallNate committed Oct 31, 2024
1 parent dee770d commit c877cbc
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 130 deletions.
4 changes: 2 additions & 2 deletions apps/tests/src/switch.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Errno } from '@nx.js/constants';
import { ENOENT } from '@nx.js/constants';
import { suite } from 'uvu';
import * as assert from 'uvu/assert';

Expand Down Expand Up @@ -185,7 +185,7 @@ test('`Switch.file()` read stream throws on ENOENT', async () => {
err = _err as Error;
}
assert.ok(err);
assert.equal((err as any).errno, Errno.ENOENT);
assert.equal((err as any).errno, ENOENT);
});

test('`Switch.file()` write stream', async () => {
Expand Down
254 changes: 126 additions & 128 deletions packages/constants/src/errno.ts
Original file line number Diff line number Diff line change
@@ -1,128 +1,126 @@
export enum Errno {
EPERM = 1 /* Not owner */,
ENOENT = 2 /* No such file or directory */,
ESRCH = 3 /* No such process */,
EINTR = 4 /* Interrupted system call */,
EIO = 5 /* I/O error */,
ENXIO = 6 /* No such device or address */,
E2BIG = 7 /* Arg list too long */,
ENOEXEC = 8 /* Exec format error */,
EBADF = 9 /* Bad file number */,
ECHILD = 10 /* No children */,
EAGAIN = 11 /* No more processes */,
ENOMEM = 12 /* Not enough space */,
EACCES = 13 /* Permission denied */,
EFAULT = 14 /* Bad address */,
ENOTBLK = 15 /* Block device required */,
EBUSY = 16 /* Device or resource busy */,
EEXIST = 17 /* File exists */,
EXDEV = 18 /* Cross-device link */,
ENODEV = 19 /* No such device */,
ENOTDIR = 20 /* Not a directory */,
EISDIR = 21 /* Is a directory */,
EINVAL = 22 /* Invalid argument */,
ENFILE = 23 /* Too many open files in system */,
EMFILE = 24 /* File descriptor value too large */,
ENOTTY = 25 /* Not a character device */,
ETXTBSY = 26 /* Text file busy */,
EFBIG = 27 /* File too large */,
ENOSPC = 28 /* No space left on device */,
ESPIPE = 29 /* Illegal seek */,
EROFS = 30 /* Read-only file system */,
EMLINK = 31 /* Too many links */,
EPIPE = 32 /* Broken pipe */,
EDOM = 33 /* Mathematics argument out of domain of function */,
ERANGE = 34 /* Result too large */,
ENOMSG = 35 /* No message of desired type */,
EIDRM = 36 /* Identifier removed */,
ECHRNG = 37 /* Channel number out of range */,
EL2NSYNC = 38 /* Level 2 not synchronized */,
EL3HLT = 39 /* Level 3 halted */,
EL3RST = 40 /* Level 3 reset */,
ELNRNG = 41 /* Link number out of range */,
EUNATCH = 42 /* Protocol driver not attached */,
ENOCSI = 43 /* No CSI structure available */,
EL2HLT = 44 /* Level 2 halted */,
EDEADLK = 45 /* Deadlock */,
ENOLCK = 46 /* No lock */,
EBADE = 50 /* Invalid exchange */,
EBADR = 51 /* Invalid request descriptor */,
EXFULL = 52 /* Exchange full */,
ENOANO = 53 /* No anode */,
EBADRQC = 54 /* Invalid request code */,
EBADSLT = 55 /* Invalid slot */,
EDEADLOCK = 56 /* File locking deadlock error */,
EBFONT = 57 /* Bad font file fmt */,
ENOSTR = 60 /* Not a stream */,
ENODATA = 61 /* No data (for no delay io) */,
ETIME = 62 /* Stream ioctl timeout */,
ENOSR = 63 /* No stream resources */,
ENONET = 64 /* Machine is not on the network */,
ENOPKG = 65 /* Package not installed */,
EREMOTE = 66 /* The object is remote */,
ENOLINK = 67 /* Virtual circuit is gone */,
EADV = 68 /* Advertise error */,
ESRMNT = 69 /* Srmount error */,
ECOMM = 70 /* Communication error on send */,
EPROTO = 71 /* Protocol error */,
EMULTIHOP = 74 /* Multihop attempted */,
ELBIN = 75 /* Inode is remote (not really error) */,
EDOTDOT = 76 /* Cross mount point (not really error) */,
EBADMSG = 77 /* Bad message */,
EFTYPE = 79 /* Inappropriate file type or format */,
ENOTUNIQ = 80 /* Given log. name not unique */,
EBADFD = 81 /* f.d. invalid for this operation */,
EREMCHG = 82 /* Remote address changed */,
ELIBACC = 83 /* Can't access a needed shared lib */,
ELIBBAD = 84 /* Accessing a corrupted shared lib */,
ELIBSCN = 85 /* .lib section in a.out corrupted */,
ELIBMAX = 86 /* Attempting to link in too many libs */,
ELIBEXEC = 87 /* Attempting to exec a shared library */,
ENOSYS = 88 /* Function not implemented */,
ENMFILE = 89 /* No more files */,
ENOTEMPTY = 90 /* Directory not empty */,
ENAMETOOLONG = 91 /* File or path name too long */,
ELOOP = 92 /* Too many symbolic links */,
EOPNOTSUPP = 95 /* Operation not supported on socket */,
EPFNOSUPPORT = 96 /* Protocol family not supported */,
ECONNRESET = 104 /* Connection reset by peer */,
ENOBUFS = 105 /* No buffer space available */,
EAFNOSUPPORT = 106 /* Address family not supported by protocol family */,
EPROTOTYPE = 107 /* Protocol wrong type for socket */,
ENOTSOCK = 108 /* Socket operation on non-socket */,
ENOPROTOOPT = 109 /* Protocol not available */,
ESHUTDOWN = 110 /* Can't send after socket shutdown */,
ECONNREFUSED = 111 /* Connection refused */,
EADDRINUSE = 112 /* Address already in use */,
ECONNABORTED = 113 /* Software caused connection abort */,
ENETUNREACH = 114 /* Network is unreachable */,
ENETDOWN = 115 /* Network interface is not configured */,
ETIMEDOUT = 116 /* Connection timed out */,
EHOSTDOWN = 117 /* Host is down */,
EHOSTUNREACH = 118 /* Host is unreachable */,
EINPROGRESS = 119 /* Connection already in progress */,
EALREADY = 120 /* Socket already connected */,
EDESTADDRREQ = 121 /* Destination address required */,
EMSGSIZE = 122 /* Message too long */,
EPROTONOSUPPORT = 123 /* Unknown protocol */,
ESOCKTNOSUPPORT = 124 /* Socket type not supported */,
EADDRNOTAVAIL = 125 /* Address not available */,
ENETRESET = 126 /* Connection aborted by network */,
EISCONN = 127 /* Socket is already connected */,
ENOTCONN = 128 /* Socket is not connected */,
ETOOMANYREFS = 129,
EPROCLIM = 130,
EUSERS = 131,
EDQUOT = 132,
ESTALE = 133,
ENOTSUP = 134 /* Not supported */,
ENOMEDIUM = 135 /* No medium (in tape drive) */,
ENOSHARE = 136 /* No such host or network path */,
ECASECLASH = 137 /* Filename exists with different case */,
EILSEQ = 138 /* Illegal byte sequence */,
EOVERFLOW = 139 /* Value too large for defined data type */,
ECANCELED = 140 /* Operation canceled */,
ENOTRECOVERABLE = 141 /* State not recoverable */,
EOWNERDEAD = 142 /* Previous owner died */,
ESTRPIPE = 143 /* Streams pipe error */,
}
export const EPERM = 1; /* Not owner */
export const ENOENT = 2; /* No such file or directory */
export const ESRCH = 3; /* No such process */
export const EINTR = 4; /* Interrupted system call */
export const EIO = 5; /* I/O error */
export const ENXIO = 6; /* No such device or address */
export const E2BIG = 7; /* Arg list too long */
export const ENOEXEC = 8; /* Exec format error */
export const EBADF = 9; /* Bad file number */
export const ECHILD = 10; /* No children */
export const EAGAIN = 11; /* No more processes */
export const ENOMEM = 12; /* Not enough space */
export const EACCES = 13; /* Permission denied */
export const EFAULT = 14; /* Bad address */
export const ENOTBLK = 15; /* Block device required */
export const EBUSY = 16; /* Device or resource busy */
export const EEXIST = 17; /* File exists */
export const EXDEV = 18; /* Cross-device link */
export const ENODEV = 19; /* No such device */
export const ENOTDIR = 20; /* Not a directory */
export const EISDIR = 21; /* Is a directory */
export const EINVAL = 22; /* Invalid argument */
export const ENFILE = 23; /* Too many open files in system */
export const EMFILE = 24; /* File descriptor value too large */
export const ENOTTY = 25; /* Not a character device */
export const ETXTBSY = 26; /* Text file busy */
export const EFBIG = 27; /* File too large */
export const ENOSPC = 28; /* No space left on device */
export const ESPIPE = 29; /* Illegal seek */
export const EROFS = 30; /* Read-only file system */
export const EMLINK = 31; /* Too many links */
export const EPIPE = 32; /* Broken pipe */
export const EDOM = 33; /* Mathematics argument out of domain of function */
export const ERANGE = 34; /* Result too large */
export const ENOMSG = 35; /* No message of desired type */
export const EIDRM = 36; /* Identifier removed */
export const ECHRNG = 37; /* Channel number out of range */
export const EL2NSYNC = 38; /* Level 2 not synchronized */
export const EL3HLT = 39; /* Level 3 halted */
export const EL3RST = 40; /* Level 3 reset */
export const ELNRNG = 41; /* Link number out of range */
export const EUNATCH = 42; /* Protocol driver not attached */
export const ENOCSI = 43; /* No CSI structure available */
export const EL2HLT = 44; /* Level 2 halted */
export const EDEADLK = 45; /* Deadlock */
export const ENOLCK = 46; /* No lock */
export const EBADE = 50; /* Invalid exchange */
export const EBADR = 51; /* Invalid request descriptor */
export const EXFULL = 52; /* Exchange full */
export const ENOANO = 53; /* No anode */
export const EBADRQC = 54; /* Invalid request code */
export const EBADSLT = 55; /* Invalid slot */
export const EDEADLOCK = 56; /* File locking deadlock error */
export const EBFONT = 57; /* Bad font file fmt */
export const ENOSTR = 60; /* Not a stream */
export const ENODATA = 61; /* No data (for no delay io) */
export const ETIME = 62; /* Stream ioctl timeout */
export const ENOSR = 63; /* No stream resources */
export const ENONET = 64; /* Machine is not on the network */
export const ENOPKG = 65; /* Package not installed */
export const EREMOTE = 66; /* The object is remote */
export const ENOLINK = 67; /* Virtual circuit is gone */
export const EADV = 68; /* Advertise error */
export const ESRMNT = 69; /* Srmount error */
export const ECOMM = 70; /* Communication error on send */
export const EPROTO = 71; /* Protocol error */
export const EMULTIHOP = 74; /* Multihop attempted */
export const ELBIN = 75; /* Inode is remote (not really error) */
export const EDOTDOT = 76; /* Cross mount point (not really error) */
export const EBADMSG = 77; /* Bad message */
export const EFTYPE = 79; /* Inappropriate file type or format */
export const ENOTUNIQ = 80; /* Given log. name not unique */
export const EBADFD = 81; /* f.d. invalid for this operation */
export const EREMCHG = 82; /* Remote address changed */
export const ELIBACC = 83; /* Can't access a needed shared lib */
export const ELIBBAD = 84; /* Accessing a corrupted shared lib */
export const ELIBSCN = 85; /* .lib section in a.out corrupted */
export const ELIBMAX = 86; /* Attempting to link in too many libs */
export const ELIBEXEC = 87; /* Attempting to exec a shared library */
export const ENOSYS = 88; /* Function not implemented */
export const ENMFILE = 89; /* No more files */
export const ENOTEMPTY = 90; /* Directory not empty */
export const ENAMETOOLONG = 91; /* File or path name too long */
export const ELOOP = 92; /* Too many symbolic links */
export const EOPNOTSUPP = 95; /* Operation not supported on socket */
export const EPFNOSUPPORT = 96; /* Protocol family not supported */
export const ECONNRESET = 104; /* Connection reset by peer */
export const ENOBUFS = 105; /* No buffer space available */
export const EAFNOSUPPORT = 106; /* Address family not supported by protocol family */
export const EPROTOTYPE = 107; /* Protocol wrong type for socket */
export const ENOTSOCK = 108; /* Socket operation on non-socket */
export const ENOPROTOOPT = 109; /* Protocol not available */
export const ESHUTDOWN = 110; /* Can't send after socket shutdown */
export const ECONNREFUSED = 111; /* Connection refused */
export const EADDRINUSE = 112; /* Address already in use */
export const ECONNABORTED = 113; /* Software caused connection abort */
export const ENETUNREACH = 114; /* Network is unreachable */
export const ENETDOWN = 115; /* Network interface is not configured */
export const ETIMEDOUT = 116; /* Connection timed out */
export const EHOSTDOWN = 117; /* Host is down */
export const EHOSTUNREACH = 118; /* Host is unreachable */
export const EINPROGRESS = 119; /* Connection already in progress */
export const EALREADY = 120; /* Socket already connected */
export const EDESTADDRREQ = 121; /* Destination address required */
export const EMSGSIZE = 122; /* Message too long */
export const EPROTONOSUPPORT = 123; /* Unknown protocol */
export const ESOCKTNOSUPPORT = 124; /* Socket type not supported */
export const EADDRNOTAVAIL = 125; /* Address not available */
export const ENETRESET = 126; /* Connection aborted by network */
export const EISCONN = 127; /* Socket is already connected */
export const ENOTCONN = 128; /* Socket is not connected */
export const ETOOMANYREFS = 129;
export const EPROCLIM = 130;
export const EUSERS = 131;
export const EDQUOT = 132;
export const ESTALE = 133;
export const ENOTSUP = 134; /* Not supported */
export const ENOMEDIUM = 135; /* No medium (in tape drive) */
export const ENOSHARE = 136; /* No such host or network path */
export const ECASECLASH = 137; /* Filename exists with different case */
export const EILSEQ = 138; /* Illegal byte sequence */
export const EOVERFLOW = 139; /* Value too large for defined data type */
export const ECANCELED = 140; /* Operation canceled */
export const ENOTRECOVERABLE = 141; /* State not recoverable */
export const EOWNERDEAD = 142; /* Previous owner died */
export const ESTRPIPE = 143; /* Streams pipe error */

0 comments on commit c877cbc

Please sign in to comment.