blob: 92535033bb932dd309f5a1308ada9a3e0e0ea22e (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Net;
namespace Test
{
class MyException : Exception
{
int _code;
public MyException(int code)
{
_code = code;
}
}
internal class Program
{
private static int Main(string[] args)
{
bool flag = false;
try
{
flag = true;
Console.WriteLine("flag={0} (should be True)", flag);
ThrowMyException(); // throws exception
}
catch (MyException)
{
Console.WriteLine("MyException Handled");
}
catch (Exception)
{
Console.WriteLine("Unknown Exception: We should never reach this line");
flag = false;
}
Console.WriteLine("flag={0} (should be True)", flag);
if (flag)
{
Console.WriteLine("PASSED");
return 100;
}
else
{
Console.WriteLine("FAILED");
return -1;
}
}
private static void ThrowMyException()
{
throw new MyException(42);
}
}
}
|