Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
void RethrowException(Exception * E)
{
  // this list has to be in sync with ExceptionMessage
  if (isa<EFatal>(E))
  {
    throw EFatal(E, L"");
  }
  else if (isa<ECallbackGuardAbort>(E))
  {
    throw ECallbackGuardAbort();
  }
  else if (isa<EAbort>(E))
  {
    throw EAbort(E->Message);
  }
  else if (WellKnownException(E, nullptr, nullptr, nullptr, true))
  {
    // noop, should never get here
  }
  else
  {
    throw ExtException(E, L"");
  }
}
Ejemplo n.º 4
0
Exception * CloneException(Exception * E)
{
  Exception * Result;
  // this list has to be in sync with ExceptionMessage
  ExtException * Ext = dyn_cast<ExtException>(E);
  if (Ext != nullptr)
  {
    Result = Ext->Clone();
  }
  else if (isa<ECallbackGuardAbort>(E))
  {
    Result = new ECallbackGuardAbort();
  }
  else if (isa<EAbort>(E))
  {
    Result = new EAbort(E->Message);
  }
  else if (WellKnownException(E, nullptr, nullptr, &Result, false))
  {
    // noop
  }
  else
  {
    // we do not expect this to happen
    if (DebugAlwaysFalse(IsInternalException(E)))
    {
      // to save exception stack trace
      Result = ExtException::CloneFrom(E);
    }
    else
    {
      Result = new Exception(E->Message);
    }
  }
  return Result;
}
Ejemplo n.º 5
0
void RethrowException(Exception * E)
{
  // this list has to be in sync with ExceptionMessage
  if (NB_STATIC_DOWNCAST(EFatal, E) != nullptr)
  {
    throw EFatal(E, L"");
  }
  else if (NB_STATIC_DOWNCAST(ECallbackGuardAbort, E) != nullptr)
  {
    throw ECallbackGuardAbort();
  }
  else if (NB_STATIC_DOWNCAST(EAbort, E) != nullptr)
  {
    throw EAbort(E->Message);
  }
  else if (WellKnownException(E, nullptr, nullptr, nullptr, true))
  {
    // noop, should never get here
  }
  else
  {
    throw ExtException(E, L"");
  }
}
Ejemplo n.º 6
0
Exception * CloneException(Exception * E)
{
  Exception * Result;
  // this list has to be in sync with ExceptionMessage
  ExtException * Ext = NB_STATIC_DOWNCAST(ExtException, E);
  if (Ext != nullptr)
  {
    Result = Ext->Clone();
  }
  else if (NB_STATIC_DOWNCAST(ECallbackGuardAbort, E) != nullptr)
  {
    Result = new ECallbackGuardAbort();
  }
  else if (NB_STATIC_DOWNCAST(EAbort, E) != nullptr)
  {
    Result = new EAbort(E->Message);
  }
  else if (WellKnownException(E, nullptr, nullptr, &Result, false))
  {
    // noop
  }
  else
  {
    // we do not expect this to happen
    if (ALWAYS_FALSE(IsInternalException(E)))
    {
      // to save exception stack trace
      Result = ExtException::CloneFrom(E);
    }
    else
    {
      Result = new Exception(E->Message);
    }
  }
  return Result;
}
Ejemplo n.º 7
0
bool IsInternalException(const Exception * E)
{
  // see also InternalError in ExceptionMessage
  return WellKnownException(E, nullptr, nullptr, nullptr, false);
}