示例#1
0
void RequestError::fallbackErrorPage(Request* request,
                                     const Exception& e,
                                     const String& e2Name)
{
	if (!request->headersSent())
	{
		request->setStatus(500);
		request->sendHeaders();
	}
	request->stream() << "<h1>“" << e.type().htmlEscape() << "” exception</h1>"
	                  << "<p>" << e.htmlMessage() << "</p>"
	                  << "<p><strong>Additionally, a “" << e2Name
	                  << "” exception was encountered while handling the "
	                  << "exception.</strong></p>"
	                  << "<h2>Stack trace</h2><ol start=\"0\">";
	List<StackTrace::Frame> stack = e.stackTrace()->stackFrames();
	for (const StackTrace::Frame& frame : stack)
	{
		request->stream() << "<li><strong><code>" << frame.function.htmlEscape()
		                  << "</code></strong> (<code>0x"
		                  << String::fromNumber(frame.address, 16)
		                  << "</code>)<br />"
		                  << "<small>in <code>" << frame.object.relativePath()
		                  << "</code>, file <code>" << frame.fileName
		                  << "</code>, line " << frame.line << "</small></li>";
	}
	request->stream() << "</ol>";
}
示例#2
0
void RequestError::loadStackTrace(Exception& e, Template* tpl)
{
	List<Variant> entries;
	List<StackTrace::Frame> stack = e.stackTrace()->stackFrames();
	for (const StackTrace::Frame& frame : stack)
	{
		Map<String, Variant> entry;
		entry["address"] = frame.address;
		entry["functionName"] = frame.function;
		entry["object"] = frame.object.relativePath();
		entry["fileName"] = frame.fileName;
		entry["line"] = frame.line;
		entries.append(entry);
	}
	tpl->set("stackTrace", entries);
}