//----------------------------------------------------------------------------// Exception::Exception(const String& message, const String& name, const String& filename, int line, const String& function) : d_message(message), d_name(name), d_filename(filename), d_line(line), d_function(function), d_what(name + " in function '" + function + "' (" + filename + ":" + PropertyHelper<int>::toString(line) + ") : " + message) { // Log exception if possible if (Logger* const logger = Logger::getSingletonPtr()) { logger->logEvent(d_what, Errors); dumpBacktrace(64); } if (d_stdErrEnabled) { // output to stderr unless it's explicitly disabled // nobody seems to look in their log file! std::cerr << what() << std::endl; } #ifdef __ANDROID__ __android_log_print(ANDROID_LOG_ERROR, "CEGUIBase", "Exception thrown: %s", what()); #endif }
void win32_exception::writelog(const char *prefix) const { if( prefix ) CLog::Log(LOGERROR, "%s : %s (code:0x%08x) at 0x%08x", prefix, (unsigned int) what(), code(), where()); else CLog::Log(LOGERROR, "%s (code:0x%08x) at 0x%08x", what(), code(), where()); }
QtException::QtException(ExceptionType exType,QString msg):exception() { setType(exType); setMessage(msg); if(exType != ExceptionType::Information) qCritical()<<getTypeAsString()<<"::"<<what(); else qDebug()<<getTypeAsString()<<"::"<<what(); }
void access_violation::writelog(const char *prefix) const { if( prefix ) if( mIsWrite ) CLog::Log(LOGERROR, "%s : %s at 0x%08x: Writing location 0x%08x", prefix, what(), where(), address()); else CLog::Log(LOGERROR, "%s : %s at 0x%08x: Reading location 0x%08x", prefix, what(), where(), address()); else if( mIsWrite ) CLog::Log(LOGERROR, "%s at 0x%08x: Writing location 0x%08x", what(), where(), address()); else CLog::Log(LOGERROR, "%s at 0x%08x: Reading location 0x%08x", what(), where(), address()); }
void GetThisHostNameRenderer::RenderAll(std::ostream &reply, Context &ctx, const ROAnything &config) { StartTrace(GetThisHostNameRenderer.RenderAll); String thisHostName; if (coast::system::HostName(thisHostName)) { String thisHostIp(Resolver::DNS2IPAddress(thisHostName)); String what(config["Representation"].AsString("Full")); if ( what.IsEqual("IPAddress") ) { reply << thisHostIp << std::flush; return; } String thisHostDns(Resolver::IPAddress2DNS(thisHostIp)); thisHostDns.ToLower(); Trace("hostname [" << thisHostName << "] ip [" << thisHostIp << "] dns [" << thisHostDns << "]"); StringTokenizer tokens(thisHostDns, '.'); String hostName, domain; if (tokens.NextToken(hostName)) { domain = tokens.GetRemainder(false); } Trace("host [" << hostName << "] domain [" << domain << "]"); if (what.IsEqual("Full")) { reply << thisHostDns; } else if (what.IsEqual("HostOnly")) { reply << hostName; } else if (what.IsEqual("DomainOnly")) { reply << domain; } reply << std::flush; } }
static void do_open(Fstream& s, const Path& path, const std::ios_base::openmode mode, typename boost::enable_if<fs::is_basic_path<Path> >::type* = 0) { try { if (!allow_read(path)) throw system_error(error_code(EACCES, get_system_category())); stream_do_open(s, path, mode); if (!s.is_open()) throw system_error(error_code(errno, get_system_category())); } catch (const system_error& e) { string what(e.std::runtime_error::what()); if (!what.empty()) what = ": " + what; what = rwu_error_message(s) + what; throw fs::filesystem_error(what, path, e.code()); } }
RWConfig GameBase::buildConfig(const std::optional<RWArgConfigLayer> &args) { RWConfig config; if (args.has_value()) { config.setLayer(RWConfig::LAYER_ARGUMENT, *args); } auto defaultLayer = buildDefaultConfigLayer(); config.setLayer(RWConfig::LAYER_DEFAULT, defaultLayer); rwfs::path configPath; if (args.has_value() && args->configPath.has_value()) { configPath = *args->configPath; } else { configPath = RWConfigParser::getDefaultConfigPath() / "openrw.ini"; } if ((!args) || (args && !args->noconfig)) { RWConfigParser configParser{}; auto [configLayer, parseResult] = configParser.loadFile(configPath); if (!parseResult.isValid()) { log.error("Config", "Could not read configuation file at " + configPath.string()); throw std::runtime_error(parseResult.what()); } config.unknown = parseResult.getUnknownData(); config.setLayer(RWConfig::LAYER_CONFIGFILE, configLayer); }
format unification_app_mismatch_exception::pp(formatter const & fmt, options const & opts) const { unsigned indent = get_pp_indent(opts); auto const & ctx = get_context(); expr const & app = get_expr(); auto args_it = get_args().begin(); auto args_end = get_args().end(); auto types_it = get_types().begin(); format app_fmt = fmt(ctx, app, false, opts); format r = format{format(what()), nest(indent, compose(line(), app_fmt))}; format fun_type_fmt = fmt(ctx, *types_it, false, opts); r += compose(line(), format("Function type:")); r += nest(indent, compose(line(), fun_type_fmt)); ++args_it; ++types_it; if (get_args().size() > 2) r += compose(line(), format("Arguments types:")); else r += compose(line(), format("Argument type:")); for (; args_it != args_end; ++args_it, ++types_it) { format arg_fmt = fmt(ctx, *args_it, false, opts); format type_fmt = fmt(ctx, *types_it, false, opts); r += nest(indent, compose(line(), group(format{arg_fmt, space(), colon(), nest(indent, format{line(), type_fmt})}))); } r += pp_elaborator_state(fmt, get_elaborator(), opts); return r; }
void Assembler::Exception::print(std::ostream &o) const { o <<what(); if (insn) o <<" while assembling [" <<unparseInstruction(insn) <<"]"; }
void RuntimeError::Log() const { if( !m_logged ) { do_log_msg( LOG_PRIORITY_ERROR, m_category.c_str(), m_function.c_str(), what() ); } }
bool InvalidAsset::CustomReport() const { LogAlwaysError << "Invalid asset (" << Initializer() << ") More information:" << std::endl << what(); return true; }
/** * @param curEnv java environment where the exception occurred. */ JniCallMethodException::JniCallMethodException(JNIEnv * curEnv) throw() : JniException(curEnv) { std::string errorMessage = "Exception when calling Java method : "; errorMessage += getJavaDescription() + "\n" + getJavaStackTrace(); errorMessage += what(); setErrorMessage(errorMessage); }
QueryData genCronTab() { QueryData results; auto system_lines = cronFromFile(kSystemCron); for (const auto& line : system_lines) { genCronLine(kSystemCron, line, results); } std::vector<std::string> user_crons; auto status = listFilesInDirectory(kUserCronsPath, user_crons); if (!status.ok()) { LOG(ERROR) << "Could not list user crons from: " << kUserCronsPath << " (" << status.what() << ")"; return results; } // The user-based crons are identified by their path. for (const auto& user_path : user_crons) { auto user_lines = cronFromFile(user_path); for (const auto& line : user_lines) { genCronLine(user_path, line, results); } } return results; }
void wxLuaConsole::DisplayStack(const wxLuaState& wxlState) { wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); int nIndex = 0; lua_Debug luaDebug = INIT_LUA_DEBUG; wxString buffer; lua_State* L = wxlState.GetLuaState(); while (lua_getstack(L, nIndex, &luaDebug) != 0) { if (lua_getinfo(L, "Sln", &luaDebug)) { wxString what (luaDebug.what ? lua2wx(luaDebug.what) : wxString(wxT("?"))); wxString nameWhat(luaDebug.namewhat ? lua2wx(luaDebug.namewhat) : wxString(wxT("?"))); wxString name (luaDebug.name ? lua2wx(luaDebug.name) : wxString(wxT("?"))); buffer += wxString::Format(wxT("[%d] %s '%s' '%s' (line %d)\n Line %d src='%s'\n"), nIndex, what.c_str(), nameWhat.c_str(), name.c_str(), luaDebug.linedefined, luaDebug.currentline, lua2wx(luaDebug.short_src).c_str()); } nIndex++; } if (!buffer.empty()) { AppendText(wxT("\n-----------------------------------------------------------") wxT("\n- Backtrace") wxT("\n-----------------------------------------------------------\n") + buffer + wxT("\n-----------------------------------------------------------\n\n")); } }
std::string _nimble_exception::to_string( __in_opt bool verbose ) { std::stringstream result; SERIALIZE_CALL_RECUR(m_lock); result << what(); #ifndef NDEBUG if(verbose) { SET_TERM_ATTRIB(result, 1, COL_FORE_YELLOW); result << " ("; if(!m_source.empty()) { result << m_source << ":"; } result << m_line << ") "; CLEAR_TERM_ATTRIB(result); } #else REF_PARAM(verbose); #endif return CHK_STR(result.str()); }
void onelab_option_cb(Fl_Widget *w, void *data) { if(!data) return; std::string what((const char*)data); double val = ((Fl_Menu_*)w)->mvalue()->value() ? 1. : 0.; if(what == "save") CTX::instance()->solver.autoSaveDatabase = val; else if(what == "archive") CTX::instance()->solver.autoArchiveOutputFiles = val; else if(what == "check"){ CTX::instance()->solver.autoCheck = val; FlGui::instance()->onelab->setButtonVisibility(); } else if(what == "mesh") CTX::instance()->solver.autoMesh = val; else if(what == "merge") CTX::instance()->solver.autoMergeFile = val; else if(what == "show") CTX::instance()->solver.autoShowViews = val ? 2 : 0; else if(what == "step") CTX::instance()->solver.autoShowLastStep = val; else if(what == "invisible"){ CTX::instance()->solver.showInvisibleParameters = val; //FlGui::instance()->onelab->rebuildTree(true); } }
basic_warning::basic_warning(const std::string& where_msg, const std::string& what_msg, type t) : my_where_msg(where_msg), my_what_msg(what_msg), my_type(t) { if (warning_stream) { std::string msg = what(); if (msg != "") { // @todo This should be handled by passing the logger as // a stream (with some appropriate wrapper deriving from basic_ostream) // but for now this will have to do. if (is_active()) { // add warning to counter if (warning_count.find(t)==warning_count.end()) warning_count[t]=1; else ++warning_count[t]; // output message if (warning_stream != logger::get_stream()) { *warning_stream << msg << std::endl; } else { // to avoid interleaving with logged messages, send // a logged message logger(logger_level::ALWAYS, where_msg, "WARNING (" + type_msg(t) + ") " + my_what_msg); } } } } }
void Parser::parsingException::searchError(std::string line, int nbLine) const { std::string error; error = "Line " + std::to_string(nbLine) + " : " + line + " : " + what(); _errorList->push_back(error); }
int server_streambuf::flush(bool end) { std::error_code e; // wait for previous responses in the pipeline to complete: { std::unique_lock<std::mutex> out_lock(act_mutex); while (!active) act_cond.wait(out_lock); } // flush headers if not already written: if (!hdrs_written) { size_t content_len; if (!query_headers_content_length(out_hdrs, content_len)) { chunked = true; #ifdef CLANE_HAVE_STD_MULTIMAP_EMPLACE out_hdrs.emplace("transfer-encoding", "chunked"); #else out_hdrs.insert(header("transfer-encoding", "chunked")); #endif } std::ostringstream ss; ss << "HTTP/" << major_ver << '.' << minor_ver << ' ' << static_cast<int>(out_stat_code) << ' ' << what(out_stat_code) << "\r\n"; for (auto i = out_hdrs.begin(); i != out_hdrs.end(); ++i) ss << canonize_1x_header_name(i->first) << ": " << i->second << "\r\n"; ss << "\r\n"; std::string hdr_lines = ss.str(); sock.send(hdr_lines.data(), hdr_lines.size(), net::all, e); if (e) return -1; // connection error hdrs_written = true; } // send: size_t chunk_len = pptr() - pbase(); if (chunk_len) { if (chunked) { std::ostringstream ss; ss << std::hex << chunk_len << "\r\n"; std::string chunk_line = ss.str(); sock.send(chunk_line.data(), chunk_line.size(), net::all, e); if (e) return -1; // connection error } sock.send(pbase(), chunk_len, net::all, e); if (e) return -1; // connection error if (chunked) { sock.send("\r\n", 2, net::all, e); if (e) return -1; // connection error } } // final chunk: if (end && chunked) { sock.send("0\r\n\r\n", 5, net::all, e); if (e) return -1; // connection error } return 0; // success }
static mode_t newmode(const char *ms, const mode_t pm) { register mode_t o, m, b; int lock, setsgid = 0, cleared = 0, copy = 0; mode_t nm, om, mm; nm = om = pm; m = absol(&ms); if (!*ms) { nm = m; goto out; } if ((lock = (nm&S_IFMT) != S_IFDIR && (nm&(S_ENFMT|S_IXGRP)) == S_ENFMT) == 01) nm &= ~(mode_t)S_ENFMT; do { m = who(&ms, &mm); while (o = what(&ms)) { b = where(&ms, nm, &lock, ©, pm); switch (o) { case '+': nm |= b & m & ~mm; if (b & S_ISGID) setsgid = 1; if (lock & 04) lock |= 02; break; case '-': nm &= ~(b & m & ~mm); if (b & S_ISGID) setsgid = 1; if (lock & 04) lock = 0; break; case '=': nm &= ~m; nm |= b & m & ~mm; lock &= ~01; if (lock & 04) lock |= 02; om = 0; if (copy == 0) cleared = 1; break; } lock &= ~04; } } while (*ms++ == ','); if (*--ms) failed(&badumask[4], badumask); out: if (pm & S_IFDIR) { if ((pm & S_ISGID) && setsgid == 0) nm |= S_ISGID; else if ((nm & S_ISGID) && setsgid == 0) nm &= ~(mode_t)S_ISGID; } return(nm); }
void WebListBox::NotifySelectChange(void) { if (mpListener) { NotifyEvent what(NOTIFIER_TYPE_LIST_BOX, NOTIFY_SELECT_CHANGE); mpListener->Notify((WebListBox*)this, &what); } }
void win32_exception::LogThrowMessage(const char *prefix) const { if( prefix ) LOG(LOGERROR, "Unhandled exception in %s : %s (code:0x%08x) at 0x%08x", prefix, (unsigned int) what(), code(), where()); else LOG(LOGERROR, "Unhandled exception in %s (code:0x%08x) at 0x%08x", what(), code(), where()); write_minidump(); }
void SDLError::outputFormattedMessage(std::ostream& os)noexcept{ os << what() << " : " << sdlErrorMessage() << "\n" << " at " << functionName() << " in " << fileName() << " line " << lineNumber() << std::endl; }
std::wstring GameException::whatw() const { std::string whatString(what()); std::wstring whatw; whatw.assign(whatString.begin(), whatString.end()); return whatw; }
string Exception::getDiagnosticInformation() const throw() { string out = "exception: "; out += what(); if (file()) return out + " (throw from " + file() + ":"+ boost::lexical_cast<string>(line()) + ")"; return out; }
void launchQuery(const std::string& name, const ScheduledQuery& query) { // Execute the scheduled query and create a named query object. VLOG(1) << "Executing query: " << query.query; auto sql = (FLAGS_enable_monitor) ? monitor(name, query) : SQL(query.query); if (!sql.ok()) { LOG(ERROR) << "Error executing query (" << query.query << "): " << sql.getMessageString(); return; } // Fill in a host identifier fields based on configuration or availability. std::string ident; auto status = getHostIdentifier(ident); if (!status.ok() || ident.empty()) { ident = "<unknown>"; } // A query log item contains an optional set of differential results or // a copy of the most-recent execution alongside some query metadata. QueryLogItem item; item.name = name; item.identifier = ident; item.time = osquery::getUnixTime(); item.calendar_time = osquery::getAsciiTime(); if (query.options.count("snapshot") && query.options.at("snapshot")) { // This is a snapshot query, emit results with a differential or state. item.snapshot_results = std::move(sql.rows()); logSnapshotQuery(item); return; } // Create a database-backed set of query results. auto dbQuery = Query(name, query); DiffResults diff_results; // Add this execution's set of results to the database-tracked named query. // We can then ask for a differential from the last time this named query // was executed by exact matching each row. status = dbQuery.addNewResults(sql.rows(), diff_results); if (!status.ok()) { LOG(ERROR) << "Error adding new results to database: " << status.what(); return; } if (diff_results.added.size() == 0 && diff_results.removed.size() == 0) { // No diff results or events to emit. return; } VLOG(1) << "Found results for query (" << name << ") for host: " << ident; item.results = diff_results; status = logQueryLogItem(item); if (!status.ok()) { LOG(ERROR) << "Error logging the results of query (" << query.query << "): " << status.toString(); } }
int main() { int stack = 10; int* heap = malloc(sizeof(int)); printf("data = %p, stack = %p, lib = %p, heap = %p\n", &data, &stack, what(), heap); return 0; }
void CRTException::display() const { TCHAR *tszMsg = mir_a2t(what()); TCHAR tszBoxMsg[500]; mir_sntprintf(tszBoxMsg, _T("%s\n\n(%s)"), tszMsg, m_szParam); ::MessageBox(0, tszBoxMsg, _T("Clist_nicer runtime error"), MB_OK | MB_ICONERROR); mir_free(tszMsg); }
// Asserts that the filename is clean for portability. // That means the function does nothing if the filename is // portable, and throws ex::Invalid if its not. void File::assertClean() { /* TODO if( !fs::portable_file_name( m_name.filename().string() )) Throw(ex::Invalid,"File Name",m_name.filename().string()); */ Node::assertClean(); if(exists() && what() != FILE) Throw(ex::Not,"File",m_name.string()); }
std::vector<std::string> get_all_messages() const { if (exceptions_.empty()) { std::vector<std::string> msgs; msgs.push_back(what()); return msgs; } return detail::get_all_messages(exceptions_); }