bool BaseExecutionContext::onFatalError(const Exception &e) { recordLastError(e); const char *file = NULL; int line = 0; if (RuntimeOption::InjectedStackTrace) { const ExtendedException *ee = dynamic_cast<const ExtendedException *>(&e); if (ee) { ArrayPtr bt = ee->getBackTrace(); if (!bt->empty()) { Array top = bt->rvalAt(0).toArray(); if (top.exists("file")) file = top.rvalAt("file").toString(); if (top.exists("line")) line = top.rvalAt("line"); } } } if (RuntimeOption::AlwaysLogUnhandledExceptions) { Logger::Log(Logger::LogError, "HipHop Fatal error: ", e, file, line); } bool handled = false; if (RuntimeOption::CallUserHandlerOnFatals) { int errnum = ErrorConstants::FATAL_ERROR; handled = callUserErrorHandler(e, errnum, true); } if (!handled && !RuntimeOption::AlwaysLogUnhandledExceptions) { Logger::Log(Logger::LogError, "HipHop Fatal error: ", e, file, line); } return handled; }
void BaseExecutionContext::handleError(const std::string &msg, int errnum, bool callUserHandler, ErrorThrowMode mode, const std::string &prefix) { SYNC_VM_REGS_SCOPED(); int newErrorState = ErrorRaised; switch (getErrorState()) { case ErrorRaised: case ErrorRaisedByUserHandler: return; case ExecutingUserHandler: newErrorState = ErrorRaisedByUserHandler; break; default: break; } ErrorStateHelper esh(this, newErrorState); ExtendedException ee(msg); recordLastError(ee, errnum); bool handled = false; if (callUserHandler) { handled = callUserErrorHandler(ee, errnum, false); } if (mode == AlwaysThrow || (mode == ThrowIfUnhandled && !handled)) { try { if (!Eval::Debugger::InterruptException(String(msg))) return; } catch (const Eval::DebuggerClientExitException &e) {} throw FatalErrorException(msg.c_str()); } if (!handled && (RuntimeOption::NoSilencer || (getErrorReportingLevel() & errnum) != 0)) { try { if (!Eval::Debugger::InterruptException(String(msg))) return; } catch (const Eval::DebuggerClientExitException &e) {} const char *file = NULL; int line = 0; if (RuntimeOption::InjectedStackTrace) { ArrayPtr bt = ee.getBackTrace(); if (!bt->empty()) { Array top = bt->rvalAt(0).toArray(); if (top.exists("file")) file = top.rvalAt("file").toString(); if (top.exists("line")) line = top.rvalAt("line"); } } Logger::Log(Logger::LogError, prefix.c_str(), ee, file, line); } }
void ExecutionContext::onFatalError(const Exception &e) { recordLastError(e); if (RuntimeOption::AlwaysLogUnhandledExceptions) { Logger::Log("HipHop Fatal error: ", e); } bool handled = false; if (RuntimeOption::CallUserHandlerOnFatals) { int64 errnum = 1; // E_ERROR handled = callUserErrorHandler(e, errnum, true); } if (!handled && !RuntimeOption::AlwaysLogUnhandledExceptions) { Logger::Log("HipHop Fatal error: ", e); } }