//--------------------------------------------------------------------------- unsigned int __fastcall ExceptionMessageDialog(Exception * E, TQueryType Type, const UnicodeString MessageFormat, unsigned int Answers, UnicodeString HelpKeyword, const TMessageParams * Params) { TStrings * MoreMessages = NULL; ExtException * EE = dynamic_cast<ExtException *>(E); if (EE != NULL) { MoreMessages = EE->MoreMessages; } UnicodeString Message; // this is always called from within ExceptionMessage check, // so it should never fail here CHECK(ExceptionMessageFormatted(E, Message)); HelpKeyword = MergeHelpKeyword(HelpKeyword, GetExceptionHelpKeyword(E)); std::unique_ptr<TStrings> OwnedMoreMessages; if (AppendExceptionStackTraceAndForget(MoreMessages)) { OwnedMoreMessages.reset(MoreMessages); } return MoreMessageDialog( FORMAT(MessageFormat.IsEmpty() ? UnicodeString(L"%s") : MessageFormat, (Message)), MoreMessages, Type, Answers, HelpKeyword, Params); }
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); } } }
bool ShouldDisplayException(Exception * E) { UnicodeString Message; return ExceptionMessageFormatted(E, Message); }