How to determine if an exception is of a particular type

前端 未结 5 541
误落风尘
误落风尘 2021-02-01 00:32

I have a piece of try catch code:

try 
{
    ...
}
catch(Exception ex) 
{
    ModelState.AddModelError(
        \"duplicateInvoiceNumberOrganisation\", \"The com         


        
5条回答
  •  半阙折子戏
    2021-02-01 01:00

    Not enough rep to comment. In response to @conterio question (in @Davide Piras answer):

    is there a catch "when not" syntax?

    There is.

    catch (Exception e) when (!(e is ArgumentException)) { }
    

提交回复
热议问题