New test.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / ExceptionContext.cs
1 /* ****************************************************************************\r
2  *\r
3  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *\r
5  * This software is subject to the Microsoft Public License (Ms-PL). \r
6  * A copy of the license can be found in the license.htm file included \r
7  * in this distribution.\r
8  *\r
9  * You must not remove this notice, or any other, from this software.\r
10  *\r
11  * ***************************************************************************/\r
12 \r
13 namespace System.Web.Mvc {\r
14     using System;\r
15     using System.Diagnostics.CodeAnalysis;\r
16 \r
17     public class ExceptionContext : ControllerContext {\r
18 \r
19         private ActionResult _result;\r
20 \r
21         // parameterless constructor used for mocking\r
22         public ExceptionContext() {\r
23         }\r
24 \r
25         [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors",\r
26             Justification = "The virtual property setters are only to support mocking frameworks, in which case this constructor shouldn't be called anyway.")]\r
27         public ExceptionContext(ControllerContext controllerContext, Exception exception)\r
28             : base(controllerContext) {\r
29             if (exception == null) {\r
30                 throw new ArgumentNullException("exception");\r
31             }\r
32 \r
33             Exception = exception;\r
34         }\r
35 \r
36         public virtual Exception Exception {\r
37             get;\r
38             set;\r
39         }\r
40 \r
41         public bool ExceptionHandled {\r
42             get;\r
43             set;\r
44         }\r
45 \r
46         public ActionResult Result {\r
47             get {\r
48                 return _result ?? EmptyResult.Instance;\r
49             }\r
50             set {\r
51                 _result = value;\r
52             }\r
53         }\r
54 \r
55     }\r
56 }\r