Changeset 17911 for trunk/Mars
- Timestamp:
- 06/16/14 17:40:48 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/fits.h
r17777 r17911 61 61 kCompUnknown, 62 62 kCompFACT 63 }; 64 65 enum fitsstate 66 { 67 throwbit = 8 63 68 }; 64 69 … … 477 482 }; 478 483 484 void Exception(const std::string &txt) 485 { 486 #ifdef __EXCEPTIONS 487 if (exceptions()&throwbit) 488 throw std::runtime_error(txt); 489 #endif 490 gLog << ___err___ << "ERROR - " << txt << std::endl; 491 } 492 479 493 protected: 480 494 std::ofstream fCopy; … … 559 573 if (!good()) 560 574 return; 575 576 EnableAddressExceptions(); 561 577 562 578 if (memcmp(simple, "SIMPLE = ", 10)) … … 697 713 { 698 714 #ifdef __EXCEPTIONS 699 throw std::runtime_error(" You are trying to read a compressed fits with the base fits class. Please use factfits instead.");700 #else 701 gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << std::endl;715 throw std::runtime_error("Trying to read a compressed fits with the base fits class. Use factfits instead."); 716 #else 717 gLog << ___err___ << "ERROR - Trying to read a compressed fits with the base fits class. Use factfits instead." << std::endl; 702 718 #endif 703 719 clear(rdstate()|std::ios::badbit); … … 711 727 { 712 728 #ifdef __EXCEPTIONS 713 throw std::runtime_error(" You are trying to read a compressed fits with the base fits class. Please use factfits instead.");714 #else 715 gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << std::endl;729 throw std::runtime_error("Trying to read a compressed fits with the base fits class. Use factfits instead."); 730 #else 731 gLog << ___err___ << "ERROR - Trying to read a compressed fits with the base fits class. Use factfits instead." << std::endl; 716 732 #endif 717 733 clear(rdstate()|std::ios::badbit); … … 853 869 } 854 870 871 void EnableAddressExceptions(bool b=true) 872 { 873 if (b) 874 exceptions(iostate(throwbit)); 875 else 876 exceptions(iostate(exceptions()&~throwbit)); 877 } 878 879 void DisableAddressExceptions() 880 { 881 EnableAddressExceptions(false); 882 } 883 855 884 void *SetPtrAddress(const std::string &name) 856 885 { … … 859 888 std::ostringstream str; 860 889 str << "SetPtrAddress('" << name << "') - Column not found."; 861 #ifdef __EXCEPTIONS 862 throw std::runtime_error(str.str()); 863 #else 864 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 890 Exception(str.str()); 865 891 return NULL; 866 #endif867 892 } 868 893 … … 888 913 std::ostringstream str; 889 914 str << "SetPtrAddress('" << name << "') - Column not found."; 890 #ifdef __EXCEPTIONS 891 throw std::runtime_error(str.str()); 892 #else 893 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 915 Exception(str.str()); 894 916 return false; 895 #endif896 917 } 897 918 … … 901 922 str << "SetPtrAddress('" << name << "') - Element size mismatch: expected " 902 923 << fTable.cols[name].size << " from header, got " << sizeof(T); 903 #ifdef __EXCEPTIONS 904 throw std::runtime_error(str.str()); 905 #else 906 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 924 Exception(str.str()); 907 925 return false; 908 #endif909 926 } 910 927 … … 914 931 str << "SetPtrAddress('" << name << "') - Element count mismatch: expected " 915 932 << fTable.cols[name].num << " from header, got " << cnt; 916 #ifdef __EXCEPTIONS 917 throw std::runtime_error(str.str()); 918 #else 919 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 933 Exception(str.str()); 920 934 return false; 921 #endif922 935 } 923 936 … … 962 975 std::ostringstream str; 963 976 str <<"SetPtrAddress('" << name << "') - Column not found."; 964 #ifdef __EXCEPTIONS 965 throw std::runtime_error(str.str()); 966 #else 967 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 977 Exception(str.str()); 968 978 return false; 969 #endif970 979 } 971 980 … … 975 984 str << "SetPtrAddress('" << name << "') - Element count mismatch: expected " 976 985 << fTable.cols[name].num << " from header, got " << cnt; 977 #ifdef __EXCEPTIONS 978 throw std::runtime_error(str.str()); 979 #else 980 gLog << ___err___ << "ERROR - " << str.str() << std::endl; 986 Exception(str.str()); 981 987 return false; 982 #endif983 988 } 984 989
Note:
See TracChangeset
for help on using the changeset viewer.