static bool ExceptionMessage(const Exception * E, bool /*Count*/, bool Formatted, UnicodeString & Message, bool & InternalError) { bool Result = true; const wchar_t * CounterName = nullptr; InternalError = false; // see also IsInternalException // this list has to be in sync with CloneException if (isa<EAbort>(E)) { Result = false; } else if (WellKnownException(E, &Message, &CounterName, nullptr, false)) { InternalError = true; } else if (E && E->Message.IsEmpty()) { Result = false; } else if (E) { Message = E->Message; } if (!Formatted) { Message = UnformatMessage(Message); } if (InternalError) { Message = FMTLOAD(REPORT_ERROR, Message.c_str()); } /* if (Count && (CounterName != nullptr) && (Configuration->Usage != nullptr)) { Configuration->Usage->Inc(CounterName); UnicodeString ExceptionDebugInfo = E->ClassName() + L":" + GetExceptionDebugInfo(); Configuration->Usage->Set(LastInternalExceptionCounter, ExceptionDebugInfo); } */ return Result; }
//--------------------------------------------------------------------------- void __fastcall TSynchronizeDialog::DoLogInternal( TSynchronizeLogEntry Entry, const UnicodeString & Message, TStrings * MoreMessages, TQueryType Type, const UnicodeString & HelpKeyword) { LogView->Items->BeginUpdate(); try { TListItem * Item = LogView->Items->Add(); TLogItemData * LogItemData = new TLogItemData(); Item->Data = LogItemData; LogItemData->Entry = Entry; LogItemData->Message = Message; if (MoreMessages != NULL) { LogItemData->MoreMessages.reset(new TStringList()); LogItemData->MoreMessages->Assign(MoreMessages); } LogItemData->Type = Type; LogItemData->HelpKeyword = HelpKeyword; Item->Caption = Now().TimeString(); UnicodeString UnformattedMessage = UnformatMessage(Message); UnformattedMessage = ReplaceStr(UnformattedMessage, L"\r", L""); UnformattedMessage = ReplaceStr(UnformattedMessage, L"\n", L" "); Item->SubItems->Add(UnformattedMessage); Item->MakeVisible(false); while (LogView->Items->Count > MaxLogItems) { LogView->Items->Delete(0); } } __finally { LogView->Items->EndUpdate(); if (Entry == slScan) { // redraw log before the scanning block update LogView->Repaint(); } } }
void ExtException::AddMoreMessages(const Exception * E) { if (E != nullptr) { if (FMoreMessages == nullptr) { FMoreMessages = new TStringList(); } const ExtException * ExtE = dyn_cast<ExtException>(E); if (ExtE != nullptr) { if (ExtE->GetMoreMessages() != nullptr) { FMoreMessages->Assign(ExtE->GetMoreMessages()); } } UnicodeString Msg; ExceptionMessageFormatted(E, Msg); // new exception does not have own message, this is in fact duplication of // the exception data, but the exception class may being changed if (Message.IsEmpty()) { Message = Msg; } else if (!Msg.IsEmpty()) { FMoreMessages->Insert(0, UnformatMessage(Msg)); } if (IsInternalException(E)) { AppendExceptionStackTraceAndForget(FMoreMessages); } if (FMoreMessages->GetCount() == 0) { SAFE_DESTROY(FMoreMessages); } } }
static bool ExceptionMessage(const Exception * E, bool /*Count*/, bool Formatted, UnicodeString & Message, bool & InternalError) { bool Result = true; const wchar_t * CounterName = nullptr; InternalError = false; // see also IsInternalException // this list has to be in sync with CloneException if (NB_STATIC_DOWNCAST_CONST(EAbort, E) != nullptr) { Result = false; } else if (WellKnownException(E, &Message, &CounterName, nullptr, false)) { InternalError = true; } else if (E && E->Message.IsEmpty()) { Result = false; } else if (E) { Message = E->Message; } if (!Formatted) { Message = UnformatMessage(Message); } if (InternalError) { Message = FMTLOAD(REPORT_ERROR, Message.c_str()); } /* if (Count && (CounterName != nullptr) && (Configuration->Usage != nullptr)) { Configuration->Usage->Inc(CounterName); } */ return Result; }
ExtException::ExtException(TObjectClassId Kind, const UnicodeString & Msg, const Exception * E, const UnicodeString & HelpKeyword) : Exception(Kind, L""), FMoreMessages(nullptr) { // "copy exception" AddMoreMessages(E); // and append message to the end to more messages if (!Msg.IsEmpty()) { if (Message.IsEmpty()) { Message = Msg; } else { if (FMoreMessages == nullptr) { FMoreMessages = new TStringList(); } FMoreMessages->Append(UnformatMessage(Msg)); } } FHelpKeyword = MergeHelpKeyword(GetExceptionHelpKeyword(E), HelpKeyword); }