44
1
using System;
2
3
// see: https://stackoverflow.com/documentation/c%23/40/exception-handling/169/using-the-exception-object#t=201706260855258771454
4
public class Program
5
{
6
7
8
void DoSomething()
9
{
10
int b=1; int c=5;
11
try
12
{
13
var a = 1;
14
b = a - 1;
15
c = a / b;
16
a = a / c;
17
}
18
catch (DivideByZeroException dEx) when (b==0)
19
{
20
// we're throwing the same kind of exception
21
throw new DivideByZeroException("Cannot divide by b because it is zero", dEx);
22
}
23
catch (DivideByZeroException dEx) when (c==0)
24
{
Cached Result