Skip to content

API Proposal: System.Exception.GetTotalExceptionCount() #36071

Closed

Description

@sywhang

Get the total exception count of the process.

public class Exception
{
    public static int GetTotalExceptionCount();
}

This is already implemented on CoreCLR side and is being used as part of the runtime performance counters. Adding this API as a public API will let customers monitor the process' exception count in-proc without having to write EventListener to consume the counters.

cc @tommcdon @noahfalk @mjsabby

Activity

  1. added
    api-suggestion
    on May 7, 2020
  2. added this to the 5.0 milestone on May 7, 2020
  3. added
    untriaged
    on May 7, 2020
  4. MichalStrehovsky commented on May 8, 2020

    @MichalStrehovsky
    Member

    It a new API really necessary? This can already be achieved using .NET Standard 2.0 APIs.

    class Program
    {
        static int s_counter;
    
        static void Main()
        {
            AppDomain.CurrentDomain.FirstChanceException += new EventHandler<FirstChanceExceptionEventArgs>((o, a) =>
            {
                Interlocked.Add(ref s_counter, 1);
            });
    
            try
            {
                throw new Exception();
            }
            catch
            {
            }
    
            Console.WriteLine(s_counter);
        }
    }
  5. removed
    untriaged
    on May 8, 2020
  6. added
    tracking
    on Jul 6, 2020
  7. modified the milestones: 5.0.0, 6.0.0 on Jul 8, 2020
  8. removed
    tracking
    on Oct 14, 2020
  9. added
    enhancement
    and removed
    enhancement
    on Nov 6, 2020
  10. ghost locked as resolved and limited conversation to collaborators on Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionarea-Diagnostics-coreclrfeature-request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions