case ESRCH: return UV_ESRCH;
case ETIMEDOUT: return UV_ETIMEDOUT;
case EXDEV: return UV_EXDEV;
+ case EBUSY: return UV_EBUSY;
+ case ENOTEMPTY: return UV_ENOTEMPTY;
default: return UV_UNKNOWN;
}
-
- assert(0 && "unreachable");
- return -1;
+ UNREACHABLE();
}
using namespace v8;
#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define THROW_BAD_ARGS \
- ThrowException(Exception::TypeError(String::New("Bad argument")))
+
+#define TYPE_ERROR(msg) \
+ ThrowException(Exception::TypeError(String::New(msg)));
+
+#define THROW_BAD_ARGS TYPE_ERROR("Bad argument")
- typedef class ReqWrap<uv_fs_t> FSReqWrap;
+ class FSReqWrap: public ReqWrap<uv_fs_t> {
+ public:
+ FSReqWrap(const char* syscall)
+ : syscall_(syscall) {
+ }
+
+ const char* syscall() { return syscall_; }
+
+ private:
+ const char* syscall_;
+ };
+
static Persistent<String> encoding_symbol;
static Persistent<String> errno_symbol;
#define ASYNC_CALL(func, callback, ...) \
- FSReqWrap* req_wrap = new FSReqWrap(); \
+ FSReqWrap* req_wrap = new FSReqWrap(#func); \
int r = uv_fs_##func(uv_default_loop(), &req_wrap->req_, \
__VA_ARGS__, After); \
- assert(r == 0); \
req_wrap->object_->Set(oncomplete_sym, callback); \
req_wrap->Dispatched(); \
+ if (r < 0) { \
+ uv_fs_t* req = &req_wrap->req_; \
+ req->result = r; \
+ req->path = NULL; \
+ req->errorno = uv_last_error(uv_default_loop()).code; \
+ After(req); \
+ } \
return scope.Close(req_wrap->object_);
#define SYNC_CALL(func, path, ...) \