forked from idg10/prog-cs-8-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rethrow.cs
42 lines (38 loc) · 781 Bytes
/
Rethrow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.IO;
namespace Exceptions
{
class Rethrow
{
public static void BadRethrow()
{
try
{
DoSomething();
}
catch (IOException x)
{
LogIOError(x);
// This next line is BAD!
throw x; // Do not do this
}
}
public static void GoodRethrow()
{
try
{
DoSomething();
}
catch (IOException x)
{
LogIOError(x);
throw;
}
}
private static void DoSomething()
{
}
private static void LogIOError(IOException x)
{
}
}
}