diff --git a/src/errors.js b/src/errors.js index f148947..9e151d3 100644 --- a/src/errors.js +++ b/src/errors.js @@ -1,69 +1,69 @@ var errors = {}; [ /** - * node.js errors + * node.js errors - we only use some of these, add as needed. */ - '-1:UNKNOWN:unknown error', - '0:OK:success', - '1:EOF:end of file', - '2:EADDRINFO:getaddrinfo error', - '3:EACCES:permission denied', - '4:EAGAIN:resource temporarily unavailable', - '5:EADDRINUSE:address already in use', - '6:EADDRNOTAVAIL:address not available', - '7:EAFNOSUPPORT:address family not supported', - '8:EALREADY:connection already in progress', + //'-1:UNKNOWN:unknown error', + //'0:OK:success', + //'1:EOF:end of file', + //'2:EADDRINFO:getaddrinfo error', + //'3:EACCES:permission denied', + //'4:EAGAIN:resource temporarily unavailable', + //'5:EADDRINUSE:address already in use', + //'6:EADDRNOTAVAIL:address not available', + //'7:EAFNOSUPPORT:address family not supported', + //'8:EALREADY:connection already in progress', '9:EBADF:bad file descriptor', '10:EBUSY:resource busy or locked', - '11:ECONNABORTED:software caused connection abort', - '12:ECONNREFUSED:connection refused', - '13:ECONNRESET:connection reset by peer', - '14:EDESTADDRREQ:destination address required', - '15:EFAULT:bad address in system call argument', - '16:EHOSTUNREACH:host is unreachable', - '17:EINTR:interrupted system call', + //'11:ECONNABORTED:software caused connection abort', + //'12:ECONNREFUSED:connection refused', + //'13:ECONNRESET:connection reset by peer', + //'14:EDESTADDRREQ:destination address required', + //'15:EFAULT:bad address in system call argument', + //'16:EHOSTUNREACH:host is unreachable', + //'17:EINTR:interrupted system call', '18:EINVAL:invalid argument', - '19:EISCONN:socket is already connected', - '20:EMFILE:too many open files', - '21:EMSGSIZE:message too long', - '22:ENETDOWN:network is down', - '23:ENETUNREACH:network is unreachable', - '24:ENFILE:file table overflow', - '25:ENOBUFS:no buffer space available', - '26:ENOMEM:not enough memory', + //'19:EISCONN:socket is already connected', + //'20:EMFILE:too many open files', + //'21:EMSGSIZE:message too long', + //'22:ENETDOWN:network is down', + //'23:ENETUNREACH:network is unreachable', + //'24:ENFILE:file table overflow', + //'25:ENOBUFS:no buffer space available', + //'26:ENOMEM:not enough memory', '27:ENOTDIR:not a directory', '28:EISDIR:illegal operation on a directory', - '29:ENONET:machine is not on the network', + //'29:ENONET:machine is not on the network', // errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js - '31:ENOTCONN:socket is not connected', - '32:ENOTSOCK:socket operation on non-socket', - '33:ENOTSUP:operation not supported on socket', + //'31:ENOTCONN:socket is not connected', + //'32:ENOTSOCK:socket operation on non-socket', + //'33:ENOTSUP:operation not supported on socket', '34:ENOENT:no such file or directory', - '35:ENOSYS:function not implemented', - '36:EPIPE:broken pipe', - '37:EPROTO:protocol error', - '38:EPROTONOSUPPORT:protocol not supported', - '39:EPROTOTYPE:protocol wrong type for socket', - '40:ETIMEDOUT:connection timed out', - '41:ECHARSET:invalid Unicode character', - '42:EAIFAMNOSUPPORT:address family for hostname not supported', + //'35:ENOSYS:function not implemented', + //'36:EPIPE:broken pipe', + //'37:EPROTO:protocol error', + //'38:EPROTONOSUPPORT:protocol not supported', + //'39:EPROTOTYPE:protocol wrong type for socket', + //'40:ETIMEDOUT:connection timed out', + //'41:ECHARSET:invalid Unicode character', + //'42:EAIFAMNOSUPPORT:address family for hostname not supported', // errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js - '44:EAISERVICE:servname not supported for ai_socktype', - '45:EAISOCKTYPE:ai_socktype not supported', - '46:ESHUTDOWN:cannot send after transport endpoint shutdown', + //'44:EAISERVICE:servname not supported for ai_socktype', + //'45:EAISOCKTYPE:ai_socktype not supported', + //'46:ESHUTDOWN:cannot send after transport endpoint shutdown', '47:EEXIST:file already exists', - '48:ESRCH:no such process', - '49:ENAMETOOLONG:name too long', - '50:EPERM:operation not permitted', + //'48:ESRCH:no such process', + //'49:ENAMETOOLONG:name too long', + //'50:EPERM:operation not permitted', '51:ELOOP:too many symbolic links encountered', - '52:EXDEV:cross-device link not permitted', + //'52:EXDEV:cross-device link not permitted', '53:ENOTEMPTY:directory not empty', - '54:ENOSPC:no space left on device', + //'54:ENOSPC:no space left on device', '55:EIO:i/o error', - '56:EROFS:read-only file system', - '57:ENODEV:no such device', - '58:ESPIPE:invalid seek', - '59:ECANCELED:operation canceled', + //'56:EROFS:read-only file system', + //'57:ENODEV:no such device', + //'58:ESPIPE:invalid seek', + //'59:ECANCELED:operation canceled', /** * Filer specific errors @@ -71,6 +71,7 @@ var errors = {}; '1000:ENOTMOUNTED:not mounted', '1001:EFILESYSTEMERROR:missing super node, use \'FORMAT\' flag to format filesystem.', '1002:ENOATTR:attribute does not exist' + ].forEach(function(e) { e = e.split(':'); var errno = +e[0]; diff --git a/tests/spec/errors.spec.js b/tests/spec/errors.spec.js index ca034cd..4604812 100644 --- a/tests/spec/errors.spec.js +++ b/tests/spec/errors.spec.js @@ -5,130 +5,130 @@ describe("Filer.Errors", function() { it("has expected errors", function() { expect(Filer.Errors).to.exist; - // By ctor - expect(Filer.Errors.UNKNOWN).to.be.a('function'); - expect(Filer.Errors.OK).to.be.a('function'); - expect(Filer.Errors.EOF).to.be.a('function'); - expect(Filer.Errors.EADDRINFO).to.be.a('function'); - expect(Filer.Errors.EACCES).to.be.a('function'); - expect(Filer.Errors.EAGAIN).to.be.a('function'); - expect(Filer.Errors.EADDRINUSE).to.be.a('function'); - expect(Filer.Errors.EADDRNOTAVAIL).to.be.a('function'); - expect(Filer.Errors.EAFNOSUPPORT).to.be.a('function'); - expect(Filer.Errors.EALREADY).to.be.a('function'); + // By ctor -- if you add some to src/errors.js, also add here + //expect(Filer.Errors.UNKNOWN).to.be.a('function'); + //expect(Filer.Errors.OK).to.be.a('function'); + //expect(Filer.Errors.EOF).to.be.a('function'); + //expect(Filer.Errors.EADDRINFO).to.be.a('function'); + //expect(Filer.Errors.EACCES).to.be.a('function'); + //expect(Filer.Errors.EAGAIN).to.be.a('function'); + //expect(Filer.Errors.EADDRINUSE).to.be.a('function'); + //expect(Filer.Errors.EADDRNOTAVAIL).to.be.a('function'); + //expect(Filer.Errors.EAFNOSUPPORT).to.be.a('function'); + //expect(Filer.Errors.EALREADY).to.be.a('function'); expect(Filer.Errors.EBADF).to.be.a('function'); expect(Filer.Errors.EBUSY).to.be.a('function'); - expect(Filer.Errors.ECONNABORTED).to.be.a('function'); - expect(Filer.Errors.ECONNREFUSED).to.be.a('function'); - expect(Filer.Errors.ECONNRESET).to.be.a('function'); - expect(Filer.Errors.EDESTADDRREQ).to.be.a('function'); - expect(Filer.Errors.EFAULT).to.be.a('function'); - expect(Filer.Errors.EHOSTUNREACH).to.be.a('function'); - expect(Filer.Errors.EINTR).to.be.a('function'); + //expect(Filer.Errors.ECONNABORTED).to.be.a('function'); + //expect(Filer.Errors.ECONNREFUSED).to.be.a('function'); + //expect(Filer.Errors.ECONNRESET).to.be.a('function'); + //expect(Filer.Errors.EDESTADDRREQ).to.be.a('function'); + //expect(Filer.Errors.EFAULT).to.be.a('function'); + //expect(Filer.Errors.EHOSTUNREACH).to.be.a('function'); + //expect(Filer.Errors.EINTR).to.be.a('function'); expect(Filer.Errors.EINVAL).to.be.a('function'); - expect(Filer.Errors.EISCONN).to.be.a('function'); - expect(Filer.Errors.EMFILE).to.be.a('function'); - expect(Filer.Errors.EMSGSIZE).to.be.a('function'); - expect(Filer.Errors.ENETDOWN).to.be.a('function'); - expect(Filer.Errors.ENETUNREACH).to.be.a('function'); - expect(Filer.Errors.ENFILE).to.be.a('function'); - expect(Filer.Errors.ENOBUFS).to.be.a('function'); - expect(Filer.Errors.ENOMEM).to.be.a('function'); + //expect(Filer.Errors.EISCONN).to.be.a('function'); + //expect(Filer.Errors.EMFILE).to.be.a('function'); + //expect(Filer.Errors.EMSGSIZE).to.be.a('function'); + //expect(Filer.Errors.ENETDOWN).to.be.a('function'); + //expect(Filer.Errors.ENETUNREACH).to.be.a('function'); + //expect(Filer.Errors.ENFILE).to.be.a('function'); + //expect(Filer.Errors.ENOBUFS).to.be.a('function'); + //expect(Filer.Errors.ENOMEM).to.be.a('function'); expect(Filer.Errors.ENOTDIR).to.be.a('function'); expect(Filer.Errors.EISDIR).to.be.a('function'); - expect(Filer.Errors.ENONET).to.be.a('function'); - expect(Filer.Errors.ENOTCONN).to.be.a('function'); - expect(Filer.Errors.ENOTSOCK).to.be.a('function'); - expect(Filer.Errors.ENOTSUP).to.be.a('function'); + //expect(Filer.Errors.ENONET).to.be.a('function'); + //expect(Filer.Errors.ENOTCONN).to.be.a('function'); + //expect(Filer.Errors.ENOTSOCK).to.be.a('function'); + //expect(Filer.Errors.ENOTSUP).to.be.a('function'); expect(Filer.Errors.ENOENT).to.be.a('function'); - expect(Filer.Errors.ENOSYS).to.be.a('function'); - expect(Filer.Errors.EPIPE).to.be.a('function'); - expect(Filer.Errors.EPROTO).to.be.a('function'); - expect(Filer.Errors.EPROTONOSUPPORT).to.be.a('function'); - expect(Filer.Errors.EPROTOTYPE).to.be.a('function'); - expect(Filer.Errors.ETIMEDOUT).to.be.a('function'); - expect(Filer.Errors.ECHARSET).to.be.a('function'); - expect(Filer.Errors.EAIFAMNOSUPPORT).to.be.a('function'); - expect(Filer.Errors.EAISERVICE).to.be.a('function'); - expect(Filer.Errors.EAISOCKTYPE).to.be.a('function'); - expect(Filer.Errors.ESHUTDOWN).to.be.a('function'); + //expect(Filer.Errors.ENOSYS).to.be.a('function'); + //expect(Filer.Errors.EPIPE).to.be.a('function'); + //expect(Filer.Errors.EPROTO).to.be.a('function'); + //expect(Filer.Errors.EPROTONOSUPPORT).to.be.a('function'); + //expect(Filer.Errors.EPROTOTYPE).to.be.a('function'); + //expect(Filer.Errors.ETIMEDOUT).to.be.a('function'); + //expect(Filer.Errors.ECHARSET).to.be.a('function'); + //expect(Filer.Errors.EAIFAMNOSUPPORT).to.be.a('function'); + //expect(Filer.Errors.EAISERVICE).to.be.a('function'); + //expect(Filer.Errors.EAISOCKTYPE).to.be.a('function'); + //expect(Filer.Errors.ESHUTDOWN).to.be.a('function'); expect(Filer.Errors.EEXIST).to.be.a('function'); - expect(Filer.Errors.ESRCH).to.be.a('function'); - expect(Filer.Errors.ENAMETOOLONG).to.be.a('function'); - expect(Filer.Errors.EPERM).to.be.a('function'); + //expect(Filer.Errors.ESRCH).to.be.a('function'); + //expect(Filer.Errors.ENAMETOOLONG).to.be.a('function'); + //expect(Filer.Errors.EPERM).to.be.a('function'); expect(Filer.Errors.ELOOP).to.be.a('function'); - expect(Filer.Errors.EXDEV).to.be.a('function'); + //expect(Filer.Errors.EXDEV).to.be.a('function'); expect(Filer.Errors.ENOTEMPTY).to.be.a('function'); - expect(Filer.Errors.ENOSPC).to.be.a('function'); + //expect(Filer.Errors.ENOSPC).to.be.a('function'); expect(Filer.Errors.EIO).to.be.a('function'); - expect(Filer.Errors.EROFS).to.be.a('function'); - expect(Filer.Errors.ENODEV).to.be.a('function'); - expect(Filer.Errors.ESPIPE).to.be.a('function'); - expect(Filer.Errors.ECANCELED).to.be.a('function'); + //expect(Filer.Errors.EROFS).to.be.a('function'); + //expect(Filer.Errors.ENODEV).to.be.a('function'); + //expect(Filer.Errors.ESPIPE).to.be.a('function'); + //expect(Filer.Errors.ECANCELED).to.be.a('function'); expect(Filer.Errors.ENOTMOUNTED).to.be.a('function'); expect(Filer.Errors.EFILESYSTEMERROR).to.be.a('function'); expect(Filer.Errors.ENOATTR).to.be.a('function'); // By errno - expect(Filer.Errors[-1]).to.equal(Filer.Errors.UNKNOWN); - expect(Filer.Errors[0]).to.equal(Filer.Errors.OK); - expect(Filer.Errors[1]).to.equal(Filer.Errors.EOF); - expect(Filer.Errors[2]).to.equal(Filer.Errors.EADDRINFO); - expect(Filer.Errors[3]).to.equal(Filer.Errors.EACCES); - expect(Filer.Errors[4]).to.equal(Filer.Errors.EAGAIN); - expect(Filer.Errors[5]).to.equal(Filer.Errors.EADDRINUSE); - expect(Filer.Errors[6]).to.equal(Filer.Errors.EADDRNOTAVAIL); - expect(Filer.Errors[7]).to.equal(Filer.Errors.EAFNOSUPPORT); - expect(Filer.Errors[8]).to.equal(Filer.Errors.EALREADY); + //expect(Filer.Errors[-1]).to.equal(Filer.Errors.UNKNOWN); + //expect(Filer.Errors[0]).to.equal(Filer.Errors.OK); + //expect(Filer.Errors[1]).to.equal(Filer.Errors.EOF); + //expect(Filer.Errors[2]).to.equal(Filer.Errors.EADDRINFO); + //expect(Filer.Errors[3]).to.equal(Filer.Errors.EACCES); + //expect(Filer.Errors[4]).to.equal(Filer.Errors.EAGAIN); + //expect(Filer.Errors[5]).to.equal(Filer.Errors.EADDRINUSE); + //expect(Filer.Errors[6]).to.equal(Filer.Errors.EADDRNOTAVAIL); + //expect(Filer.Errors[7]).to.equal(Filer.Errors.EAFNOSUPPORT); + //expect(Filer.Errors[8]).to.equal(Filer.Errors.EALREADY); expect(Filer.Errors[9]).to.equal(Filer.Errors.EBADF); expect(Filer.Errors[10]).to.equal(Filer.Errors.EBUSY); - expect(Filer.Errors[11]).to.equal(Filer.Errors.ECONNABORTED); - expect(Filer.Errors[12]).to.equal(Filer.Errors.ECONNREFUSED); - expect(Filer.Errors[13]).to.equal(Filer.Errors.ECONNRESET); - expect(Filer.Errors[14]).to.equal(Filer.Errors.EDESTADDRREQ); - expect(Filer.Errors[15]).to.equal(Filer.Errors.EFAULT); - expect(Filer.Errors[16]).to.equal(Filer.Errors.EHOSTUNREACH); - expect(Filer.Errors[17]).to.equal(Filer.Errors.EINTR); + //expect(Filer.Errors[11]).to.equal(Filer.Errors.ECONNABORTED); + //expect(Filer.Errors[12]).to.equal(Filer.Errors.ECONNREFUSED); + //expect(Filer.Errors[13]).to.equal(Filer.Errors.ECONNRESET); + //expect(Filer.Errors[14]).to.equal(Filer.Errors.EDESTADDRREQ); + //expect(Filer.Errors[15]).to.equal(Filer.Errors.EFAULT); + //expect(Filer.Errors[16]).to.equal(Filer.Errors.EHOSTUNREACH); + //expect(Filer.Errors[17]).to.equal(Filer.Errors.EINTR); expect(Filer.Errors[18]).to.equal(Filer.Errors.EINVAL); - expect(Filer.Errors[19]).to.equal(Filer.Errors.EISCONN); - expect(Filer.Errors[20]).to.equal(Filer.Errors.EMFILE); - expect(Filer.Errors[21]).to.equal(Filer.Errors.EMSGSIZE); - expect(Filer.Errors[22]).to.equal(Filer.Errors.ENETDOWN); - expect(Filer.Errors[23]).to.equal(Filer.Errors.ENETUNREACH); - expect(Filer.Errors[24]).to.equal(Filer.Errors.ENFILE); - expect(Filer.Errors[25]).to.equal(Filer.Errors.ENOBUFS); - expect(Filer.Errors[26]).to.equal(Filer.Errors.ENOMEM); + //expect(Filer.Errors[19]).to.equal(Filer.Errors.EISCONN); + //expect(Filer.Errors[20]).to.equal(Filer.Errors.EMFILE); + //expect(Filer.Errors[21]).to.equal(Filer.Errors.EMSGSIZE); + //expect(Filer.Errors[22]).to.equal(Filer.Errors.ENETDOWN); + //expect(Filer.Errors[23]).to.equal(Filer.Errors.ENETUNREACH); + //expect(Filer.Errors[24]).to.equal(Filer.Errors.ENFILE); + //expect(Filer.Errors[25]).to.equal(Filer.Errors.ENOBUFS); + //expect(Filer.Errors[26]).to.equal(Filer.Errors.ENOMEM); expect(Filer.Errors[27]).to.equal(Filer.Errors.ENOTDIR); expect(Filer.Errors[28]).to.equal(Filer.Errors.EISDIR); - expect(Filer.Errors[29]).to.equal(Filer.Errors.ENONET); - expect(Filer.Errors[31]).to.equal(Filer.Errors.ENOTCONN); - expect(Filer.Errors[32]).to.equal(Filer.Errors.ENOTSOCK); - expect(Filer.Errors[33]).to.equal(Filer.Errors.ENOTSUP); + //expect(Filer.Errors[29]).to.equal(Filer.Errors.ENONET); + //expect(Filer.Errors[31]).to.equal(Filer.Errors.ENOTCONN); + //expect(Filer.Errors[32]).to.equal(Filer.Errors.ENOTSOCK); + //expect(Filer.Errors[33]).to.equal(Filer.Errors.ENOTSUP); expect(Filer.Errors[34]).to.equal(Filer.Errors.ENOENT); - expect(Filer.Errors[35]).to.equal(Filer.Errors.ENOSYS); - expect(Filer.Errors[36]).to.equal(Filer.Errors.EPIPE); - expect(Filer.Errors[37]).to.equal(Filer.Errors.EPROTO); - expect(Filer.Errors[38]).to.equal(Filer.Errors.EPROTONOSUPPORT); - expect(Filer.Errors[39]).to.equal(Filer.Errors.EPROTOTYPE); - expect(Filer.Errors[40]).to.equal(Filer.Errors.ETIMEDOUT); - expect(Filer.Errors[41]).to.equal(Filer.Errors.ECHARSET); - expect(Filer.Errors[42]).to.equal(Filer.Errors.EAIFAMNOSUPPORT); - expect(Filer.Errors[44]).to.equal(Filer.Errors.EAISERVICE); - expect(Filer.Errors[45]).to.equal(Filer.Errors.EAISOCKTYPE); - expect(Filer.Errors[46]).to.equal(Filer.Errors.ESHUTDOWN); + //expect(Filer.Errors[35]).to.equal(Filer.Errors.ENOSYS); + //expect(Filer.Errors[36]).to.equal(Filer.Errors.EPIPE); + //expect(Filer.Errors[37]).to.equal(Filer.Errors.EPROTO); + //expect(Filer.Errors[38]).to.equal(Filer.Errors.EPROTONOSUPPORT); + //expect(Filer.Errors[39]).to.equal(Filer.Errors.EPROTOTYPE); + //expect(Filer.Errors[40]).to.equal(Filer.Errors.ETIMEDOUT); + //expect(Filer.Errors[41]).to.equal(Filer.Errors.ECHARSET); + //expect(Filer.Errors[42]).to.equal(Filer.Errors.EAIFAMNOSUPPORT); + //expect(Filer.Errors[44]).to.equal(Filer.Errors.EAISERVICE); + //expect(Filer.Errors[45]).to.equal(Filer.Errors.EAISOCKTYPE); + //expect(Filer.Errors[46]).to.equal(Filer.Errors.ESHUTDOWN); expect(Filer.Errors[47]).to.equal(Filer.Errors.EEXIST); - expect(Filer.Errors[48]).to.equal(Filer.Errors.ESRCH); - expect(Filer.Errors[49]).to.equal(Filer.Errors.ENAMETOOLONG); - expect(Filer.Errors[50]).to.equal(Filer.Errors.EPERM); + //expect(Filer.Errors[48]).to.equal(Filer.Errors.ESRCH); + //expect(Filer.Errors[49]).to.equal(Filer.Errors.ENAMETOOLONG); + //expect(Filer.Errors[50]).to.equal(Filer.Errors.EPERM); expect(Filer.Errors[51]).to.equal(Filer.Errors.ELOOP); - expect(Filer.Errors[52]).to.equal(Filer.Errors.EXDEV); + //expect(Filer.Errors[52]).to.equal(Filer.Errors.EXDEV); expect(Filer.Errors[53]).to.equal(Filer.Errors.ENOTEMPTY); - expect(Filer.Errors[54]).to.equal(Filer.Errors.ENOSPC); + //expect(Filer.Errors[54]).to.equal(Filer.Errors.ENOSPC); expect(Filer.Errors[55]).to.equal(Filer.Errors.EIO); - expect(Filer.Errors[56]).to.equal(Filer.Errors.EROFS); - expect(Filer.Errors[57]).to.equal(Filer.Errors.ENODEV); - expect(Filer.Errors[58]).to.equal(Filer.Errors.ESPIPE); - expect(Filer.Errors[59]).to.equal(Filer.Errors.ECANCELED); + //expect(Filer.Errors[56]).to.equal(Filer.Errors.EROFS); + //expect(Filer.Errors[57]).to.equal(Filer.Errors.ENODEV); + //expect(Filer.Errors[58]).to.equal(Filer.Errors.ESPIPE); + //expect(Filer.Errors[59]).to.equal(Filer.Errors.ECANCELED); expect(Filer.Errors[1000]).to.equal(Filer.Errors.ENOTMOUNTED); expect(Filer.Errors[1001]).to.equal(Filer.Errors.EFILESYSTEMERROR); expect(Filer.Errors[1002]).to.equal(Filer.Errors.ENOATTR);