About 50 results
Open links in new tab
  1. c# - Catch multiple exceptions at once? - Stack Overflow

    If a method's throwing 32 different types of exceptions, it's badly written. It's either not catching exceptions it's own calls are making, it's doing FAR too much in one method, or the majority/all of …

  2. c# - try- catch. Handling multiple exceptions the same way (or with a ...

    Jul 23, 2015 · Unless the exception all derive from a base exception you need to consider refactoring the common logic to a method and call it from the different exception handlers. Alternatively you could do …

  3. Catching multiple exception in C# - Stack Overflow

    Dec 6, 2018 · 4 You can catch specific exceptions and have multiple catch blocks, you don't need to do the if statements. I'm guessing it doesn't like the fact that you're catching just Exception and not the …

  4. c# - Catch two exceptions in the same catch block? - Stack Overflow

    Apr 6, 2011 · Actually this is the only new feature in C# 6 that is not possible to emulate in prior versions. First, a re-throw means more overhead than skipping the catch. Second, it is not semantically …

  5. Possible syntax for multi-type catch blocks in C#?

    Catch multiple Exceptions at once? More Elegant Exception Handling Than Multiple Catch Blocks? I was working today and thought this might be an appropriate syntax should this feature ever be …

  6. c# - How to catch all types of exception in one single catch block ...

    Oct 4, 2012 · An alternative that can result in concise, readable code is to use the is operator which evaluates to true if your exception is an instance of a particular type or one that derives from that type.

  7. c# - Multiple-exception catches - Stack Overflow

    Jun 26, 2012 · The determination of whether or not to catch Ex is made before any inner Finally blocks run. Unfortunately, the makers of C# dislike the idea of allowing custom exception filters, perhaps …

  8. c# - Can I execute multiple Catch blocks? - Stack Overflow

    Oct 27, 2010 · It is perfectly acceptable to have multiple catch blocks of differring types. However, the behavior is that the first candidate block handles the exception. It will not enter BOTH catch blocks. …

  9. c# - More Elegant Exception Handling Than Multiple Catch Blocks ...

    Dec 6, 2014 · Closed 12 years ago. Using C#, is there a better way to handle multiple types of exceptions rather than a bunch of ugly catch blocks? What is considered best practice for this type of …

  10. C# How to handle multiple exceptions which does all the same?

    Jun 15, 2015 · As has been stated above its always best to catch the right type of exception where possible. The code works by specifying the exceptions as generic type arguments to the handle …