| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 71432c3 commit 57a0cd4
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -819,7 +819,7 @@ void Environment::CollectExceptionInfo(Local<Value> object, | |||
| 819 | 819 | return; | |
| 820 | 820 | ||
| 821 | 821 | Local<Object> obj = object.As<Object>(); | |
| 822 | - const char* err_string = node::errno_string(errorno); | ||
| 822 | + const char* err_string = errors::errno_string(errorno); | ||
| 823 | 823 | ||
| 824 | 824 | if (message == nullptr || message[0] == '\0') { | |
| 825 | 825 | message = strerror(errorno); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,11 @@ | |||
| 1 | - #include "node.h" | ||
| 2 | - #include "node_internals.h" | ||
| 1 | + // This file contains implementation of error APIs exposed in node.h | ||
| 2 | + | ||
| 3 | 3 | #include "env-inl.h" | |
| 4 | + #include "node.h" | ||
| 5 | + #include "node_errors.h" | ||
| 4 | 6 | #include "util-inl.h" | |
| 5 | - #include "v8.h" | ||
| 6 | 7 | #include "uv.h" | |
| 8 | + #include "v8.h" | ||
| 7 | 9 | ||
| 8 | 10 | #include <string.h> | |
| 9 | 11 | ||
@@ -27,7 +29,7 @@ Local<Value> ErrnoException(Isolate* isolate, | |||
| 27 | 29 | Environment* env = Environment::GetCurrent(isolate); | |
| 28 | 30 | ||
| 29 | 31 | Local<Value> e; | |
| 30 | - Local<String> estring = OneByteString(isolate, errno_string(errorno)); | ||
| 32 | + Local<String> estring = OneByteString(isolate, errors::errno_string(errorno)); | ||
| 31 | 33 | if (msg == nullptr || msg[0] == '\0') { | |
| 32 | 34 | msg = strerror(errorno); | |
| 33 | 35 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | + #include <errno.h> | ||
| 1 | 2 | #include <stdarg.h> | |
| 3 | + | ||
| 2 | 4 | #include "node_errors.h" | |
| 3 | 5 | #include "node_internals.h" | |
| 4 | 6 | ||
@@ -322,6 +324,334 @@ TryCatchScope::~TryCatchScope() { | |||
| 322 | 324 | } | |
| 323 | 325 | } | |
| 324 | 326 | ||
| 327 | + const char* errno_string(int errorno) { | ||
| 328 | + #define ERRNO_CASE(e) \ | ||
| 329 | + case e: \ | ||
| 330 | + return #e; | ||
| 331 | + switch (errorno) { | ||
| 332 | + #ifdef EACCES | ||
| 333 | + ERRNO_CASE(EACCES); | ||
| 334 | + #endif | ||
| 335 | + | ||
| 336 | + #ifdef EADDRINUSE | ||
| 337 | + ERRNO_CASE(EADDRINUSE); | ||
| 338 | + #endif | ||
| 339 | + | ||
| 340 | + #ifdef EADDRNOTAVAIL | ||
| 341 | + ERRNO_CASE(EADDRNOTAVAIL); | ||
| 342 | + #endif | ||
| 343 | + | ||
| 344 | + #ifdef EAFNOSUPPORT | ||
| 345 | + ERRNO_CASE(EAFNOSUPPORT); | ||
| 346 | + #endif | ||
| 347 | + | ||
| 348 | + #ifdef EAGAIN | ||
| 349 | + ERRNO_CASE(EAGAIN); | ||
| 350 | + #endif | ||
| 351 | + | ||
| 352 | + #ifdef EWOULDBLOCK | ||
| 353 | + #if EAGAIN != EWOULDBLOCK | ||
| 354 | + ERRNO_CASE(EWOULDBLOCK); | ||
| 355 | + #endif | ||
| 356 | + #endif | ||
| 357 | + | ||
| 358 | + #ifdef EALREADY | ||
| 359 | + ERRNO_CASE(EALREADY); | ||
| 360 | + #endif | ||
| 361 | + | ||
| 362 | + #ifdef EBADF | ||
| 363 | + ERRNO_CASE(EBADF); | ||
| 364 | + #endif | ||
| 365 | + | ||
| 366 | + #ifdef EBADMSG | ||
| 367 | + ERRNO_CASE(EBADMSG); | ||
| 368 | + #endif | ||
| 369 | + | ||
| 370 | + #ifdef EBUSY | ||
| 371 | + ERRNO_CASE(EBUSY); | ||
| 372 | + #endif | ||
| 373 | + | ||
| 374 | + #ifdef ECANCELED | ||
| 375 | + ERRNO_CASE(ECANCELED); | ||
| 376 | + #endif | ||
| 377 | + | ||
| 378 | + #ifdef ECHILD | ||
| 379 | + ERRNO_CASE(ECHILD); | ||
| 380 | + #endif | ||
| 381 | + | ||
| 382 | + #ifdef ECONNABORTED | ||
| 383 | + ERRNO_CASE(ECONNABORTED); | ||
| 384 | + #endif | ||
| 385 | + | ||
| 386 | + #ifdef ECONNREFUSED | ||
| 387 | + ERRNO_CASE(ECONNREFUSED); | ||
| 388 | + #endif | ||
| 389 | + | ||
| 390 | + #ifdef ECONNRESET | ||
| 391 | + ERRNO_CASE(ECONNRESET); | ||
| 392 | + #endif | ||
| 393 | + | ||
| 394 | + #ifdef EDEADLK | ||
| 395 | + ERRNO_CASE(EDEADLK); | ||
| 396 | + #endif | ||
| 397 | + | ||
| 398 | + #ifdef EDESTADDRREQ | ||
| 399 | + ERRNO_CASE(EDESTADDRREQ); | ||
| 400 | + #endif | ||
| 401 | + | ||
| 402 | + #ifdef EDOM | ||
| 403 | + ERRNO_CASE(EDOM); | ||
| 404 | + #endif | ||
| 405 | + | ||
| 406 | + #ifdef EDQUOT | ||
| 407 | + ERRNO_CASE(EDQUOT); | ||
| 408 | + #endif | ||
| 409 | + | ||
| 410 | + #ifdef EEXIST | ||
| 411 | + ERRNO_CASE(EEXIST); | ||
| 412 | + #endif | ||
| 413 | + | ||
| 414 | + #ifdef EFAULT | ||
| 415 | + ERRNO_CASE(EFAULT); | ||
| 416 | + #endif | ||
| 417 | + | ||
| 418 | + #ifdef EFBIG | ||
| 419 | + ERRNO_CASE(EFBIG); | ||
| 420 | + #endif | ||
| 421 | + | ||
| 422 | + #ifdef EHOSTUNREACH | ||
| 423 | + ERRNO_CASE(EHOSTUNREACH); | ||
| 424 | + #endif | ||
| 425 | + | ||
| 426 | + #ifdef EIDRM | ||
| 427 | + ERRNO_CASE(EIDRM); | ||
| 428 | + #endif | ||
| 429 | + | ||
| 430 | + #ifdef EILSEQ | ||
| 431 | + ERRNO_CASE(EILSEQ); | ||
| 432 | + #endif | ||
| 433 | + | ||
| 434 | + #ifdef EINPROGRESS | ||
| 435 | + ERRNO_CASE(EINPROGRESS); | ||
| 436 | + #endif | ||
| 437 | + | ||
| 438 | + #ifdef EINTR | ||
| 439 | + ERRNO_CASE(EINTR); | ||
| 440 | + #endif | ||
| 441 | + | ||
| 442 | + #ifdef EINVAL | ||
| 443 | + ERRNO_CASE(EINVAL); | ||
| 444 | + #endif | ||
| 445 | + | ||
| 446 | + #ifdef EIO | ||
| 447 | + ERRNO_CASE(EIO); | ||
| 448 | + #endif | ||
| 449 | + | ||
| 450 | + #ifdef EISCONN | ||
| 451 | + ERRNO_CASE(EISCONN); | ||
| 452 | + #endif | ||
| 453 | + | ||
| 454 | + #ifdef EISDIR | ||
| 455 | + ERRNO_CASE(EISDIR); | ||
| 456 | + #endif | ||
| 457 | + | ||
| 458 | + #ifdef ELOOP | ||
| 459 | + ERRNO_CASE(ELOOP); | ||
| 460 | + #endif | ||
| 461 | + | ||
| 462 | + #ifdef EMFILE | ||
| 463 | + ERRNO_CASE(EMFILE); | ||
| 464 | + #endif | ||
| 465 | + | ||
| 466 | + #ifdef EMLINK | ||
| 467 | + ERRNO_CASE(EMLINK); | ||
| 468 | + #endif | ||
| 469 | + | ||
| 470 | + #ifdef EMSGSIZE | ||
| 471 | + ERRNO_CASE(EMSGSIZE); | ||
| 472 | + #endif | ||
| 473 | + | ||
| 474 | + #ifdef EMULTIHOP | ||
| 475 | + ERRNO_CASE(EMULTIHOP); | ||
| 476 | + #endif | ||
| 477 | + | ||
| 478 | + #ifdef ENAMETOOLONG | ||
| 479 | + ERRNO_CASE(ENAMETOOLONG); | ||
| 480 | + #endif | ||
| 481 | + | ||
| 482 | + #ifdef ENETDOWN | ||
| 483 | + ERRNO_CASE(ENETDOWN); | ||
| 484 | + #endif | ||
| 485 | + | ||
| 486 | + #ifdef ENETRESET | ||
| 487 | + ERRNO_CASE(ENETRESET); | ||
| 488 | + #endif | ||
| 489 | + | ||
| 490 | + #ifdef ENETUNREACH | ||
| 491 | + ERRNO_CASE(ENETUNREACH); | ||
| 492 | + #endif | ||
| 493 | + | ||
| 494 | + #ifdef ENFILE | ||
| 495 | + ERRNO_CASE(ENFILE); | ||
| 496 | + #endif | ||
| 497 | + | ||
| 498 | + #ifdef ENOBUFS | ||
| 499 | + ERRNO_CASE(ENOBUFS); | ||
| 500 | + #endif | ||
| 501 | + | ||
| 502 | + #ifdef ENODATA | ||
| 503 | + ERRNO_CASE(ENODATA); | ||
| 504 | + #endif | ||
| 505 | + | ||
| 506 | + #ifdef ENODEV | ||
| 507 | + ERRNO_CASE(ENODEV); | ||
| 508 | + #endif | ||
| 509 | + | ||
| 510 | + #ifdef ENOENT | ||
| 511 | + ERRNO_CASE(ENOENT); | ||
| 512 | + #endif | ||
| 513 | + | ||
| 514 | + #ifdef ENOEXEC | ||
| 515 | + ERRNO_CASE(ENOEXEC); | ||
| 516 | + #endif | ||
| 517 | + | ||
| 518 | + #ifdef ENOLINK | ||
| 519 | + ERRNO_CASE(ENOLINK); | ||
| 520 | + #endif | ||
| 521 | + | ||
| 522 | + #ifdef ENOLCK | ||
| 523 | + #if ENOLINK != ENOLCK | ||
| 524 | + ERRNO_CASE(ENOLCK); | ||
| 525 | + #endif | ||
| 526 | + #endif | ||
| 527 | + | ||
| 528 | + #ifdef ENOMEM | ||
| 529 | + ERRNO_CASE(ENOMEM); | ||
| 530 | + #endif | ||
| 531 | + | ||
| 532 | + #ifdef ENOMSG | ||
| 533 | + ERRNO_CASE(ENOMSG); | ||
| 534 | + #endif | ||
| 535 | + | ||
| 536 | + #ifdef ENOPROTOOPT | ||
| 537 | + ERRNO_CASE(ENOPROTOOPT); | ||
| 538 | + #endif | ||
| 539 | + | ||
| 540 | + #ifdef ENOSPC | ||
| 541 | + ERRNO_CASE(ENOSPC); | ||
| 542 | + #endif | ||
| 543 | + | ||
| 544 | + #ifdef ENOSR | ||
| 545 | + ERRNO_CASE(ENOSR); | ||
| 546 | + #endif | ||
| 547 | + | ||
| 548 | + #ifdef ENOSTR | ||
| 549 | + ERRNO_CASE(ENOSTR); | ||
| 550 | + #endif | ||
| 551 | + | ||
| 552 | + #ifdef ENOSYS | ||
| 553 | + ERRNO_CASE(ENOSYS); | ||
| 554 | + #endif | ||
| 555 | + | ||
| 556 | + #ifdef ENOTCONN | ||
| 557 | + ERRNO_CASE(ENOTCONN); | ||
| 558 | + #endif | ||
| 559 | + | ||
| 560 | + #ifdef ENOTDIR | ||
| 561 | + ERRNO_CASE(ENOTDIR); | ||
| 562 | + #endif | ||
| 563 | + | ||
| 564 | + #ifdef ENOTEMPTY | ||
| 565 | + #if ENOTEMPTY != EEXIST | ||
| 566 | + ERRNO_CASE(ENOTEMPTY); | ||
| 567 | + #endif | ||
| 568 | + #endif | ||
| 569 | + | ||
| 570 | + #ifdef ENOTSOCK | ||
| 571 | + ERRNO_CASE(ENOTSOCK); | ||
| 572 | + #endif | ||
| 573 | + | ||
| 574 | + #ifdef ENOTSUP | ||
| 575 | + ERRNO_CASE(ENOTSUP); | ||
| 576 | + #else | ||
| 577 | + #ifdef EOPNOTSUPP | ||
| 578 | + ERRNO_CASE(EOPNOTSUPP); | ||
| 579 | + #endif | ||
| 580 | + #endif | ||
| 581 | + | ||
| 582 | + #ifdef ENOTTY | ||
| 583 | + ERRNO_CASE(ENOTTY); | ||
| 584 | + #endif | ||
| 585 | + | ||
| 586 | + #ifdef ENXIO | ||
| 587 | + ERRNO_CASE(ENXIO); | ||
| 588 | + #endif | ||
| 589 | + | ||
| 590 | + #ifdef EOVERFLOW | ||
| 591 | + ERRNO_CASE(EOVERFLOW); | ||
| 592 | + #endif | ||
| 593 | + | ||
| 594 | + #ifdef EPERM | ||
| 595 | + ERRNO_CASE(EPERM); | ||
| 596 | + #endif | ||
| 597 | + | ||
| 598 | + #ifdef EPIPE | ||
| 599 | + ERRNO_CASE(EPIPE); | ||
| 600 | + #endif | ||
| 601 | + | ||
| 602 | + #ifdef EPROTO | ||
| 603 | + ERRNO_CASE(EPROTO); | ||
| 604 | + #endif | ||
| 605 | + | ||
| 606 | + #ifdef EPROTONOSUPPORT | ||
| 607 | + ERRNO_CASE(EPROTONOSUPPORT); | ||
| 608 | + #endif | ||
| 609 | + | ||
| 610 | + #ifdef EPROTOTYPE | ||
| 611 | + ERRNO_CASE(EPROTOTYPE); | ||
| 612 | + #endif | ||
| 613 | + | ||
| 614 | + #ifdef ERANGE | ||
| 615 | + ERRNO_CASE(ERANGE); | ||
| 616 | + #endif | ||
| 617 | + | ||
| 618 | + #ifdef EROFS | ||
| 619 | + ERRNO_CASE(EROFS); | ||
| 620 | + #endif | ||
| 621 | + | ||
| 622 | + #ifdef ESPIPE | ||
| 623 | + ERRNO_CASE(ESPIPE); | ||
| 624 | + #endif | ||
| 625 | + | ||
| 626 | + #ifdef ESRCH | ||
| 627 | + ERRNO_CASE(ESRCH); | ||
| 628 | + #endif | ||
| 629 | + | ||
| 630 | + #ifdef ESTALE | ||
| 631 | + ERRNO_CASE(ESTALE); | ||
| 632 | + #endif | ||
| 633 | + | ||
| 634 | + #ifdef ETIME | ||
| 635 | + ERRNO_CASE(ETIME); | ||
| 636 | + #endif | ||
| 637 | + | ||
| 638 | + #ifdef ETIMEDOUT | ||
| 639 | + ERRNO_CASE(ETIMEDOUT); | ||
| 640 | + #endif | ||
| 641 | + | ||
| 642 | + #ifdef ETXTBSY | ||
| 643 | + ERRNO_CASE(ETXTBSY); | ||
| 644 | + #endif | ||
| 645 | + | ||
| 646 | + #ifdef EXDEV | ||
| 647 | + ERRNO_CASE(EXDEV); | ||
| 648 | + #endif | ||
| 649 | + | ||
| 650 | + default: | ||
| 651 | + return ""; | ||
| 652 | + } | ||
| 653 | + } | ||
| 654 | + | ||
| 325 | 655 | } // namespace errors | |
| 326 | 656 | ||
| 327 | 657 | void DecorateErrorStack(Environment* env, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -188,11 +188,12 @@ class TryCatchScope : public v8::TryCatch { | |||
| 188 | 188 | CatchMode mode_; | |
| 189 | 189 | }; | |
| 190 | 190 | ||
| 191 | + const char* errno_string(int errorno); | ||
| 192 | + | ||
| 191 | 193 | } // namespace errors | |
| 192 | 194 | ||
| 193 | 195 | void DecorateErrorStack(Environment* env, | |
| 194 | 196 | const errors::TryCatchScope& try_catch); | |
| 195 | - | ||
| 196 | 197 | } // namespace node | |
| 197 | 198 | ||
| 198 | 199 | #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| Back | FazBrowse Home | New Git URL |
0 commit comments