Can I not catch a specific or custom exception?

后端 未结 6 1656
余生分开走
余生分开走 2021-01-18 02:16

I dont want to catch some exception. Can I do it somehow?

Can I say something like this:

catch (Exception e BUT not CustomExceptionA)
{
}
         


        
6条回答
  •  旧时难觅i
    2021-01-18 03:00

    You can filter it:

    if (e is CustomExceptionA) throw;
    

    And of course you can catch it and rethrow it:

    try
    {
    }
    catch (CustomExceptionA) { throw; }
    catch (Exception ex) { ... }
    

提交回复
热议问题