@@ -56,11 +56,6 @@ static Persistent<String> errno_symbol;
56
56
static Persistent<String> buf_symbol;
57
57
static Persistent<String> oncomplete_sym;
58
58
59
- Local<Value> FSError (int errorno,
60
- const char *syscall = NULL ,
61
- const char *msg = NULL ,
62
- const char *path = NULL );
63
-
64
59
65
60
#ifdef _LARGEFILE_SOURCE
66
61
static inline int IsInt64 (double x) {
@@ -91,12 +86,12 @@ static void After(uv_fs_t *req) {
91
86
// If the request doesn't have a path parameter set.
92
87
93
88
if (!req->path ) {
94
- argv[0 ] = FSError (req->errorno );
89
+ argv[0 ] = UVException (req->errorno );
95
90
} else {
96
- argv[0 ] = FSError (req->errorno ,
97
- NULL ,
98
- NULL ,
99
- static_cast <const char *>(req->path ));
91
+ argv[0 ] = UVException (req->errorno ,
92
+ NULL ,
93
+ NULL ,
94
+ static_cast <const char *>(req->path ));
100
95
}
101
96
} else {
102
97
// error value is empty or null for non-error.
@@ -210,82 +205,6 @@ struct fs_req_wrap {
210
205
};
211
206
212
207
213
- const char * errno_string (int errorno) {
214
- uv_err_t err;
215
- memset (&err, 0 , sizeof err);
216
- err.code = (uv_err_code)errorno;
217
- return uv_err_name (err);
218
- }
219
-
220
-
221
- const char * errno_message (int errorno) {
222
- uv_err_t err;
223
- memset (&err, 0 , sizeof err);
224
- err.code = (uv_err_code)errorno;
225
- return uv_strerror (err);
226
- }
227
-
228
-
229
- // hack alert! copy of ErrnoException in node.cc, tuned for uv errors
230
- Local<Value> FSError (int errorno,
231
- const char *syscall,
232
- const char *msg,
233
- const char *path) {
234
- static Persistent<String> syscall_symbol;
235
- static Persistent<String> errpath_symbol;
236
- static Persistent<String> code_symbol;
237
-
238
- if (syscall_symbol.IsEmpty ()) {
239
- syscall_symbol = NODE_PSYMBOL (" syscall" );
240
- errno_symbol = NODE_PSYMBOL (" errno" );
241
- errpath_symbol = NODE_PSYMBOL (" path" );
242
- code_symbol = NODE_PSYMBOL (" code" );
243
- }
244
-
245
- if (!msg || !msg[0 ])
246
- msg = errno_message (errorno);
247
-
248
- Local<String> estring = String::NewSymbol (errno_string (errorno));
249
- Local<String> message = String::NewSymbol (msg);
250
- Local<String> cons1 = String::Concat (estring, String::NewSymbol (" , " ));
251
- Local<String> cons2 = String::Concat (cons1, message);
252
-
253
- Local<Value> e;
254
-
255
- Local<String> path_str;
256
-
257
- if (path) {
258
- #ifdef _WIN32
259
- if (strncmp (path, " \\\\ ?\\ UNC\\ " , 8 ) == 0 ) {
260
- path_str = String::Concat (String::New (" \\\\ " ), String::New (path + 8 ));
261
- } else if (strncmp (path, " \\\\ ?\\ " , 4 ) == 0 ) {
262
- path_str = String::New (path + 4 );
263
- } else {
264
- path_str = String::New (path);
265
- }
266
- #else
267
- path_str = String::New (path);
268
- #endif
269
-
270
- Local<String> cons3 = String::Concat (cons2, String::NewSymbol (" '" ));
271
- Local<String> cons4 = String::Concat (cons3, path_str);
272
- Local<String> cons5 = String::Concat (cons4, String::NewSymbol (" '" ));
273
- e = Exception::Error (cons5);
274
- } else {
275
- e = Exception::Error (cons2);
276
- }
277
-
278
- Local<Object> obj = e->ToObject ();
279
-
280
- // TODO errno should probably go
281
- obj->Set (errno_symbol, Integer::New (errorno));
282
- obj->Set (code_symbol, estring);
283
- if (path) obj->Set (errpath_symbol, path_str);
284
- if (syscall ) obj->Set (syscall_symbol, String::NewSymbol (syscall ));
285
- return e;
286
- }
287
-
288
-
289
208
#define ASYNC_CALL (func, callback, ...) \
290
209
FSReqWrap* req_wrap = new FSReqWrap(); \
291
210
int r = uv_fs_##func(uv_default_loop(), &req_wrap->req_, \
@@ -300,7 +219,7 @@ Local<Value> FSError(int errorno,
300
219
int result = uv_fs_##func(uv_default_loop(), &req_wrap.req, __VA_ARGS__, NULL ); \
301
220
if (result < 0 ) { \
302
221
int code = uv_last_error (uv_default_loop ()).code ; \
303
- return ThrowException (FSError (code, #func, " " , path)); \
222
+ return ThrowException (UVException (code, #func, " " , path)); \
304
223
}
305
224
306
225
#define SYNC_REQ req_wrap.req
0 commit comments