EFatal::EFatal(const Exception * E, const UnicodeString & Msg, const UnicodeString & HelpKeyword) : ExtException(Msg, E, HelpKeyword), FReopenQueried(false) { const EFatal * F = NB_STATIC_DOWNCAST_CONST(EFatal, E); if (F != nullptr) { FReopenQueried = F->GetReopenQueried(); } }
void TGUICopyParamType::Assign(const TCopyParamType * Source) { TCopyParamType::Assign(Source); const TGUICopyParamType * GUISource; GUISource = NB_STATIC_DOWNCAST_CONST(TGUICopyParamType, Source); if (GUISource != nullptr) { GUIAssign(GUISource); } }
void TStrings::Assign(const TPersistent * Source) { const TStrings * Strings = NB_STATIC_DOWNCAST_CONST(TStrings, Source); if (Strings != nullptr) { BeginUpdate(); SCOPE_EXIT { EndUpdate(); }; Clear(); DebugAssert(Strings); FQuoteChar = Strings->FQuoteChar; FDelimiter = Strings->FDelimiter; AddStrings(Strings); }
UnicodeString GetExceptionHelpKeyword(const Exception * E) { UnicodeString HelpKeyword; const ExtException * ExtE = NB_STATIC_DOWNCAST_CONST(ExtException, E); UnicodeString Message; // not used bool InternalError = false; if (ExtE != nullptr) { HelpKeyword = ExtE->GetHelpKeyword(); } else if ((E != nullptr) && ExceptionMessage(E, false, false, Message, InternalError) && InternalError) { HelpKeyword = HELP_INTERNAL_ERROR; } return HelpKeyword; }
void ExtException::AddMoreMessages(const Exception * E) { if (E != nullptr) { if (FMoreMessages == nullptr) { FMoreMessages = new TStringList(); } const ExtException * ExtE = NB_STATIC_DOWNCAST_CONST(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; }
static bool WellKnownException( const Exception * E, UnicodeString * AMessage, const wchar_t ** ACounterName, Exception ** AClone, bool Rethrow) { UnicodeString Message; const wchar_t * CounterName = nullptr; std::unique_ptr<Exception> Clone; bool Result = true; // EAccessViolation is EExternal if (NB_STATIC_DOWNCAST_CONST(EAccessViolation, E) != nullptr) { if (Rethrow) { throw EAccessViolation(E->Message); } Message = MainInstructions(LoadStr(ACCESS_VIOLATION_ERROR3)); CounterName = L"AccessViolations"; Clone.reset(new EAccessViolation(E->Message)); } /* // EIntError and EMathError are EExternal else if ((NB_STATIC_DOWNCAST(EListError, E) != nullptr) || (NB_STATIC_DOWNCAST(EStringListError, E) != nullptr) || (NB_STATIC_DOWNCAST(EIntError, E) != nullptr) || (NB_STATIC_DOWNCAST(EMathError, E) != nullptr) || (NB_STATIC_DOWNCAST(EVariantError, E) != nullptr) || (NB_STATIC_DOWNCAST(EInvalidOperation, E) != nullptr)) { if (Rethrow) { throw EIntError(E->Message); } Message = E->Message; CounterName = L"InternalExceptions"; Clone.reset(new EIntError(E->Message)); } else if (NB_STATIC_DOWNCAST(EExternal, E) != nullptr) { if (Rethrow) { throw EExternal(E->Message); } Message = MainInstructions(E->Message); CounterName = L"ExternalExceptions"; Clone.reset(new EExternal(E->Message)); } else if (NB_STATIC_DOWNCAST(EHeapException, E) != nullptr) { if (Rethrow) { throw EHeapException(E->Message); } Message = MainInstructions(E->Message); CounterName = L"HeapExceptions"; Clone.reset(new EHeapException(E->Message)); } */ else { Result = false; } if (Result) { if (AMessage != nullptr) { (*AMessage) = Message; } if (ACounterName != nullptr) { (*ACounterName) = CounterName; } if (AClone != nullptr) { (*AClone) = NOT_NULL(Clone.release()); } } return Result; }