Changeset 1785:606178a14011 in lemon-0.x
- Timestamp:
- 11/10/05 13:40:58 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2323
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/error.h
r1746 r1785 499 499 500 500 501 inline502 void assert_fail(const char *file, int line, const char *func,503 const char *message, const char *assertion = 0,501 template <typename Exception> 502 inline void assert_fail(const char *file, int line, const char *func, 503 Exception exception, const char *assertion = 0, 504 504 bool do_abort=true) 505 { 506 using namespace std; 507 cerr << file << ":" << line << ": "; 508 if( func ) 509 cerr << func << ": "; 510 cerr << exception.what(); 511 if( assertion ) 512 cerr << " (assertion '" << assertion << "' failed)"; 513 cerr << endl; 514 if(do_abort) 515 abort(); 516 } 517 518 template <> 519 inline void assert_fail<const char *>(const char *file, int line, const char *func, 520 const char *message, 521 const char *assertion, 522 bool do_abort) 505 523 { 506 524 using namespace std; … … 516 534 } 517 535 518 inline 519 void assert_fail_throw(const char *file, int line, const char *func, 520 const char *message, const char *assertion = 0, 521 bool = true) 536 template <typename Exception> 537 inline void assert_fail_failure(const char *file, int line, const char *func, 538 Exception exception, 539 const char *assertion = 0, 540 bool = true) 541 { 542 throw AssertionFailedError(file, line, func, exception.what(), assertion); 543 } 544 545 template <> 546 inline void assert_fail_failure<const char *>(const char *file, int line, 547 const char *func, 548 const char *message, 549 const char *assertion, 550 bool) 522 551 { 523 552 throw AssertionFailedError(file, line, func, message, assertion); 524 553 } 525 554 555 template <typename Exception> 556 inline void assert_fail_exception(const char *file, int line, const char *func, 557 Exception exception, 558 const char *assertion = 0, bool = true) 559 { 560 throw exception; 561 } 562 563 template <> 564 inline void assert_fail_exception<const char *>(const char *file, int line, 565 const char *func, 566 const char *message, 567 const char *assertion, 568 bool) 569 { 570 throw AssertionFailedError(file, line, func, message, assertion); 571 } 572 526 573 /// @} 527 574 … … 537 584 538 585 #ifndef LEMON_ASSERT_HANDLER 539 # ifdef LEMON_ASSERT_EXCEPTION 540 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail_throw 586 # if defined LEMON_ASSERT_EXCEPTION 587 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail_exception 588 # elif defined LEMON_ASSERT_FAILURE 589 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail_failure 541 590 # else 542 591 # define LEMON_ASSERT_HANDLER ::lemon::assert_fail … … 563 612 * 564 613 * \todo This whole 'assert' business should be placed in a separate 565 * include file. 614 * include file. The boost assert is not guarded by header sentries 615 * which may help to change the behaviour of the assertions in 616 * the files. 566 617 * 567 618 * \todo __PRETTY_FUNCTION__ should be replaced by something
Note: See TracChangeset
for help on using the changeset viewer.