示例#1
0
文件: ilog.cpp 项目: karagog/gutil
ILog::LoggingData ILog::PrepareExceptionData(const Exception<false> &e)
{
    LoggingData ret;
    ret.MessageLevel = LogLevelError;
    ret.Message = e.Message();
    ret.Title = String::Format("%s caught", e.what());
    return ret;
}
示例#2
0
文件: ilog.cpp 项目: karagog/gutil
ILog::LoggingData ILog::PrepareExceptionData(const Exception<true> &e)
{
    LoggingData ret;
    ret.MessageLevel = LogLevelError;

    String data_string{""};
    const unordered_map<string, string> &keys( e.Data );
    if(keys.size() > 0){
        data_string = "\n\nException Data:";
        for(const auto &p : keys){
            data_string.Append(String::Format("\n\tKey: %s   Value: %s",
                                              p.first.data(),
                                              p.second.data()));
        }
    }

    ret.Message = String::Format("%s%s", e.Message().data(), data_string.ConstData());
    ret.Title = String::Format("%s caught%s",
                             e.what(),
                             e.GetInnerException() ? " (Inner exception follows immediately)" : "");
    return ret;
}
示例#3
0
//Generate an error result set from an exception.
//Per LSCP spec, error result is a sinle line in the following format:
//ERR:<CODE>:Message text\r\n
//This method will be used to generate unknown errors only (code 0)
//To generate errors with other codes as well as warnings use other methods (below).
//Because this is an unknown error, this method will also print message to the stderr.
void LSCPResultSet::Error(Exception e) {
        e.PrintMessage();
	Error(e.Message());
}
示例#4
0
void OpenHome::UnhandledExceptionHandler(Exception& aException)
{
    Bws<5> thName;
    GetThreadName(thName);
    char buf[1024];
    (void)snprintf(buf, sizeof(buf), "Unhandled exception %s at %s:%lu in thread %s\n", aException.Message(), aException.File(), (unsigned long)aException.Line(), thName.Ptr());

    TInt len = 8*1024;
    char* msg = new char[len];
    if (msg != NULL) {
        (void)strncpy(msg, buf, len);
        len -= (TInt)strlen(buf);
        (void)strncat(msg, "\n", len);
        len -= 2;

        THandle stackTrace = aException.StackTrace();
        TUint count = Os::StackTraceNumEntries(stackTrace);
        for (TUint i=0; i<count; i++) {
            const char* entry = Os::StackTraceEntry(stackTrace, i);
            (void)strncat(msg, entry, len);
            len -= (TInt)strlen(entry) + 2;
            if (len < 0) {
                break;
            }
            (void)strncat(msg, "\n", len);
        }
    }
    if (len > 0) {
        (void)strncat(msg, "\n", len);
    }

    CallFatalErrorHandler((msg!=NULL? msg : buf));
    delete msg;
}