void raise_error(const char* pfunction, const char* pmessage, const T& val) { if(pfunction == 0) pfunction = "Unknown function operating on type %1%"; if(pmessage == 0) pmessage = "Cause unknown: error caused by bad argument with value %1%"; std::string function(pfunction); std::string message(pmessage); std::string msg("Error in function "); #ifndef BOOST_NO_RTTI replace_all_in_string(function, "%1%", boost::math::policies::detail::name_of<T>()); #else replace_all_in_string(function, "%1%", "Unknown"); #endif msg += function; msg += ": "; std::string sval = prec_format(val); replace_all_in_string(message, "%1%", sval.c_str()); msg += message; E e(msg); boost::throw_exception(e); }
/* * replace the variables in command from the config file (%INPUT_FILE%, %OUTPUT_FILE% and %QUALITY%) */ char* format_command(char *config_command, int currentFile) { char* command = strdup(config_command); char* replaced = NULL; replaced = replace_all_in_string(command, INPUT_FILE, input_files[currentFile]); free(command); command = strdup(replaced); free(replaced); replaced = replace_all_in_string(command, OUTPUT_FILE, output_filenames[currentFile]); free(command); command = strdup(replaced); free(replaced); replaced = replace_all_in_string(command, QUALITY, quality); free(command); command = strdup(replaced); free(replaced); return command; }
inline T raise_overflow_error( const char* function, const char* message, const T& val, const ::boost::math::policies::overflow_error< ::boost::math::policies::user_error>&) { std::string m(message ? message : ""); std::string sval = prec_format(val); replace_all_in_string(m, "%1%", sval.c_str()); return user_overflow_error(function, m.c_str(), std::numeric_limits<T>::infinity()); }
void raise_error(const char* pfunction, const char* message) { if(pfunction == 0) pfunction = "Unknown function operating on type %1%"; if(message == 0) message = "Cause unknown"; std::string function(pfunction); std::string msg("Error in function "); #ifndef BOOST_NO_RTTI replace_all_in_string(function, "%1%", boost::math::policies::detail::name_of<T>()); #else replace_all_in_string(function, "%1%", "Unknown"); #endif msg += function; msg += ": "; msg += message; E e(msg); boost::throw_exception(e); }