src/Microsoft.PowerShell.Commands.Management/commands/management/CommandsCommon.cs
// Keep in sync:
// S.M.A.CommandProcessorBase.CheckForSevereException
// S.M.A.Internal.ConsoleHost.CheckForSevereException
// S.M.A.Commands.CommandsCommon.CheckForSevereException
// S.M.A.Commands.UtilityCommon.CheckForSevereException
/// <summary>
/// Checks whether the exception is a severe exception which should
/// cause immediate process failure.
/// </summary>
/// <param name="cmdlet"></param>
/// <param name="e"></param>
/// <remarks>
/// CB says 02/23/2005: I personally would err on the side
/// of treating OOM like an application exception, rather than
/// a critical system failure.I think this will be easier to justify
/// in Orcas, if we tease apart the two cases of OOM better.
/// But even in Whidbey, how likely is it that we couldnt JIT
/// some backout code?  At that point, the process or possibly
/// the machine is likely to stop executing soon no matter
/// what you do in this routine.  So I would just consider
/// AccessViolationException.  (I understand why you have SO here,
/// at least temporarily).
/// </remarks>
Checks whether the exception is a severe exception which should
cause immediate process failure.
Checks whether the exception is a severe exception which should cause immediate process failure .
internal static void CheckForSevereException(Cmdlet cmdlet, Exception e)
        {
            if (e is AccessViolationException || e is StackOverflowException)
            {
                try
                {
                    if (!alreadyFailing)
                    {
                        alreadyFailing = true;
                        MshLog.LogCommandHealthEvent(
                            cmdlet.Context,
                            e,
                            Severity.Critical);
                    }
                }
                finally
                {
                    if (!designForTestability_SkipFailFast)
                        WindowsErrorReporting.FailFast(e);
                }
            }
        }
internal static void CheckForSevereException ( Cmdlet cmdlet , Exception e ) { if ( e is AccessViolationException || e is StackOverflowException ) { try { if ( ! alreadyFailing ) { alreadyFailing = true ; MshLog . LogCommandHealthEvent ( cmdlet . Context , e , Severity . Critical ) ; } } finally { if ( ! designForTestability_SkipFailFast ) WindowsErrorReporting . FailFast ( e ) ; } } }
Checks whether the exception is a severe exception which should
cause immediate process failure.
Checks whether the exception is a severe exception which should cause immediate process failure .
// Log a command health event for this critical error.
cmdlet
Cmdlet
None
e
Exception
None
remarks
CB says 02/23/2005: I personally would err on the side
of treating OOM like an application exception, rather than
a critical system failure.I think this will be easier to justify
in Orcas, if we tease apart the two cases of OOM better.
But even in Whidbey, how likely is it that we couldnt JIT
some backout code.  At that point, the process or possibly
the machine is likely to stop executing soon no matter
what you do in this routine.  So I would just consider
AccessViolationException.  (I understand why you have SO here,
at least temporarily).
CB says 02 / 23 / 2005 : I personally would err on the side of treating OOM like an application exception rather than a critical system failure . I think this will be easier to justify in Orcas if we tease apart the two cases of OOM better . But even in Whidbey how likely is it that we couldnt JIT some backout code . At that point the process or possibly the machine is likely to stop executing soon no matter what you do in this routine . So I would just consider AccessViolationException . ( I understand why you have SO here at least temporarily ) .