in prod/native/libphpbridge/code/Exceptions.cpp [103:139]
std::string exceptionToString(zend_object *exception) {
if (!exception || !instanceof_function(exception->ce, zend_ce_throwable)) {
return {};
}
std::stringstream msg;
auto exceptionClass = getExceptionClass(exception);
auto exceptionName = getExceptionName(exception);
msg << exceptionClass.value_or(exceptionName);
msg << " thrown"sv;
auto message = getExceptionMessage(exception);
if (message.has_value()) {
msg << " with message '"sv << *message << "'";
}
auto code = getExceptionCode(exception);
if (code.has_value() && *code != 0) {
msg << " with code "sv << *code;
}
auto fileName = getExceptionFileName(exception);
if (fileName.has_value()) {
msg << " in "sv << *fileName;
auto line = getExceptionLine(exception);
if (line.has_value()) {
msg << ":"sv << *line;
}
}
auto stack = getExceptionStringStackTrace(exception);
if (stack.has_value() && !stack.value().empty()) {
msg << " stacktrace: '"sv << *stack << "'";
}
return msg.str();
}