Test for match of current state with list of error conditions. Fix type and code of the exception.
| 709 | |
| 710 | // Test for match of current state with list of error conditions. Fix type and code of the exception. |
| 711 | bool BlockNode::testAndFixupError(thread_db* tdbb, Request* request, const ExceptionArray& conditions) |
| 712 | { |
| 713 | if (tdbb->tdbb_flags & TDBB_sys_error) |
| 714 | return false; |
| 715 | |
| 716 | Jrd::FbStatusVector* statusVector = tdbb->tdbb_status_vector; |
| 717 | |
| 718 | bool found = false; |
| 719 | |
| 720 | for (USHORT i = 0; i < conditions.getCount(); i++) |
| 721 | { |
| 722 | switch (conditions[i].type) |
| 723 | { |
| 724 | case ExceptionItem::SQL_CODE: |
| 725 | { |
| 726 | const SSHORT sqlcode = gds__sqlcode(statusVector->getErrors()); |
| 727 | if (sqlcode == conditions[i].code) |
| 728 | found = true; |
| 729 | } |
| 730 | break; |
| 731 | |
| 732 | case ExceptionItem::SQL_STATE: |
| 733 | { |
| 734 | FB_SQLSTATE_STRING sqlstate; |
| 735 | fb_sqlstate(sqlstate, statusVector->getErrors()); |
| 736 | if (conditions[i].name == sqlstate) |
| 737 | found = true; |
| 738 | } |
| 739 | break; |
| 740 | |
| 741 | case ExceptionItem::GDS_CODE: |
| 742 | if (statusVector->getErrors()[1] == conditions[i].code) |
| 743 | found = true; |
| 744 | break; |
| 745 | |
| 746 | case ExceptionItem::XCP_CODE: |
| 747 | // Look at set_error() routine to understand how the |
| 748 | // exception ID info is encoded inside the status vector. |
| 749 | if ((statusVector->getErrors()[1] == isc_except) && |
| 750 | (statusVector->getErrors()[3] == conditions[i].code)) |
| 751 | { |
| 752 | found = true; |
| 753 | } |
| 754 | |
| 755 | break; |
| 756 | |
| 757 | case ExceptionItem::XCP_DEFAULT: |
| 758 | found = true; |
| 759 | break; |
| 760 | |
| 761 | default: |
| 762 | fb_assert(false); |
| 763 | } |
| 764 | |
| 765 | if (found) |
| 766 | { |
| 767 | request->req_last_xcp.init(statusVector); |
| 768 | fb_utils::init_status(statusVector); |
nothing calls this directly
no test coverage detected