/**This method throws the error string returned by gsoap to mantid upper layer *@param icat :: -ICat proxy object */ void CErrorHandling::throwErrorMessages(ICat3::ICATPortBindingProxy &icat) { char buf[600]; const int len = 600; icat.soap_sprint_fault(buf, len); std::string error(buf); std::string begmsg("<message>"); std::string endmsg("</message>"); std::basic_string<char>::size_type index1 = error.find(begmsg); std::basic_string<char>::size_type index2 = error.find(endmsg); std::string exception; if (index1 != std::string::npos && index2 != std::string::npos) { exception = error.substr(index1 + begmsg.length(), index2 - (index1 + begmsg.length())); } throw std::runtime_error(exception); }
/** * Throws an error message (returned by gsoap) to Mantid upper layer. * @param icat :: ICATPortBindingProxy object. */ void ICat4Catalog::throwErrorMessage(ICATPortBindingProxy &icat) { char buf[600]; const int len = 600; icat.soap_sprint_fault(buf, len); std::string error(buf); std::string begmsg("<message>"); std::string endmsg("</message>"); std::basic_string<char>::size_type start = error.find(begmsg); std::basic_string<char>::size_type end = error.find(endmsg); std::string exception; if (start != std::string::npos && end != std::string::npos) { exception = error.substr(start + begmsg.length(), end - (start + begmsg.length())); } // If no error is returned by ICAT then there is a connection problem. if (exception.empty()) exception = "ICAT appears to be offline. Please check your connection or " "report this issue."; throw std::runtime_error(exception); }