-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomException.cs
More file actions
40 lines (35 loc) · 804 Bytes
/
CustomException.cs
File metadata and controls
40 lines (35 loc) · 804 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for CustomException
/// </summary>
using System.Runtime.Serialization;
[DataContract]
public class CustomException
{
[DataMember(Order = 0)]
public string Message { get; set; }
[DataMember(Order = 1)]
public CustomException InnerException;
public CustomException(Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
this.Message = ex.Message + ex.StackTrace;
}
public Exception ToException()
{
Exception e;
CustomException ce = this;
if (ce.InnerException != null)
{
Exception inner = ce.InnerException.ToException();
e = new Exception(ce.Message, inner);
}
else
e = new Exception(ce.Message);
return e;
}
}