2014-05-23 18:14:06 +00:00
|
|
|
var errors = {};
|
|
|
|
[
|
|
|
|
/**
|
2014-08-19 01:31:25 +00:00
|
|
|
* node.js errors - we only use some of these, add as needed.
|
2014-05-23 18:14:06 +00:00
|
|
|
*/
|
2014-08-19 01:31:25 +00:00
|
|
|
//'-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',
|
2014-05-23 18:14:06 +00:00
|
|
|
'9:EBADF:bad file descriptor',
|
|
|
|
'10:EBUSY:resource busy or locked',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'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',
|
2014-05-23 18:14:06 +00:00
|
|
|
'18:EINVAL:invalid argument',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'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',
|
2014-05-23 18:14:06 +00:00
|
|
|
'27:ENOTDIR:not a directory',
|
|
|
|
'28:EISDIR:illegal operation on a directory',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'29:ENONET:machine is not on the network',
|
2014-05-23 18:14:06 +00:00
|
|
|
// errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
|
2014-08-19 01:31:25 +00:00
|
|
|
//'31:ENOTCONN:socket is not connected',
|
|
|
|
//'32:ENOTSOCK:socket operation on non-socket',
|
|
|
|
//'33:ENOTSUP:operation not supported on socket',
|
2014-05-23 18:14:06 +00:00
|
|
|
'34:ENOENT:no such file or directory',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'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',
|
2014-05-23 18:14:06 +00:00
|
|
|
// errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js
|
2014-08-19 01:31:25 +00:00
|
|
|
//'44:EAISERVICE:servname not supported for ai_socktype',
|
|
|
|
//'45:EAISOCKTYPE:ai_socktype not supported',
|
|
|
|
//'46:ESHUTDOWN:cannot send after transport endpoint shutdown',
|
2014-05-23 18:14:06 +00:00
|
|
|
'47:EEXIST:file already exists',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'48:ESRCH:no such process',
|
|
|
|
//'49:ENAMETOOLONG:name too long',
|
2014-09-24 15:22:29 +00:00
|
|
|
'50:EPERM:operation not permitted',
|
2014-05-23 18:14:06 +00:00
|
|
|
'51:ELOOP:too many symbolic links encountered',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'52:EXDEV:cross-device link not permitted',
|
2014-05-23 18:14:06 +00:00
|
|
|
'53:ENOTEMPTY:directory not empty',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'54:ENOSPC:no space left on device',
|
2014-05-23 18:14:06 +00:00
|
|
|
'55:EIO:i/o error',
|
2014-08-19 01:31:25 +00:00
|
|
|
//'56:EROFS:read-only file system',
|
|
|
|
//'57:ENODEV:no such device',
|
|
|
|
//'58:ESPIPE:invalid seek',
|
|
|
|
//'59:ECANCELED:operation canceled',
|
2014-03-12 20:23:03 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
/**
|
|
|
|
* Filer specific errors
|
|
|
|
*/
|
|
|
|
'1000:ENOTMOUNTED:not mounted',
|
|
|
|
'1001:EFILESYSTEMERROR:missing super node, use \'FORMAT\' flag to format filesystem.',
|
|
|
|
'1002:ENOATTR:attribute does not exist'
|
2014-08-19 01:31:25 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
].forEach(function(e) {
|
|
|
|
e = e.split(':');
|
2014-08-18 23:21:35 +00:00
|
|
|
var errno = +e[0];
|
|
|
|
var errName = e[1];
|
|
|
|
var defaultMessage = e[2];
|
2014-03-12 20:23:03 +00:00
|
|
|
|
2014-08-18 23:13:50 +00:00
|
|
|
function FilerError(msg, path) {
|
2014-08-19 01:04:09 +00:00
|
|
|
Error.call(this);
|
|
|
|
|
2014-08-18 23:21:35 +00:00
|
|
|
this.name = errName;
|
|
|
|
this.code = errName;
|
2014-07-24 16:24:47 +00:00
|
|
|
this.errno = errno;
|
2014-08-18 23:21:35 +00:00
|
|
|
this.message = msg || defaultMessage;
|
2014-08-18 23:13:50 +00:00
|
|
|
if(path) {
|
|
|
|
this.path = path;
|
|
|
|
}
|
2014-08-19 01:04:09 +00:00
|
|
|
this.stack = (new Error(this.message)).stack;
|
2014-05-23 18:14:06 +00:00
|
|
|
}
|
2014-07-24 16:24:47 +00:00
|
|
|
FilerError.prototype = Object.create(Error.prototype);
|
|
|
|
FilerError.prototype.constructor = FilerError;
|
2014-08-18 23:13:50 +00:00
|
|
|
FilerError.prototype.toString = function() {
|
|
|
|
var pathInfo = this.path ? (', \'' + this.path + '\'') : '';
|
2014-08-18 23:21:35 +00:00
|
|
|
return this.name + ': ' + this.message + pathInfo;
|
2014-08-18 23:13:50 +00:00
|
|
|
};
|
2014-03-12 20:23:03 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
// We expose the error as both Errors.EINVAL and Errors[18]
|
2014-08-18 23:21:35 +00:00
|
|
|
errors[errName] = errors[errno] = FilerError;
|
2013-11-08 20:33:44 +00:00
|
|
|
});
|
2014-05-23 18:14:06 +00:00
|
|
|
|
|
|
|
module.exports = errors;
|