Merge pull request #1691 from esdrubal/exitevent
[mono.git] / mcs / class / corlib / System.Runtime.InteropServices / ManagedErrorInfo.cs
1 // ManagedErrorInfo class
2 //
3 // Eberhard Beilharz (eb1@sil.org)
4 //
5 // Copyright (C) 2012 SIL International
6
7 #if FEATURE_COMINTEROP
8
9 using System;
10 using System.Runtime.CompilerServices;
11 using System.Security;
12
13 namespace System.Runtime.InteropServices
14 {
15         /// <summary>
16         /// Helper class that allows to pass an exception as an IErrorInfo object. This is useful
17         /// when we get an exception in managed code that is called from unmanaged code that is called
18         /// from managed code and we want to get to the exception in the outer managed code.
19         /// </summary>
20         internal class ManagedErrorInfo: IErrorInfo
21         {
22                 private Exception m_Exception;
23                 public ManagedErrorInfo (Exception e)
24                 {
25                         m_Exception = e;
26                 }
27
28                 public Exception Exception {
29                         get { return m_Exception; }
30                 }
31
32                 #region IErrorInfo
33                 public int GetGUID (out Guid guid)
34                 {
35                         // not supported
36                         guid = Guid.Empty;
37                         return 0;
38                 }
39
40                 public int GetSource (out string source)
41                 {
42                         source = m_Exception.Source;
43                         return 0;
44                 }
45
46                 public int GetDescription (out string description)
47                 {
48                         description = m_Exception.Message;
49                         return 0;
50                 }
51
52                 public int GetHelpFile (out string helpFile)
53                 {
54                         helpFile = m_Exception.HelpLink;
55                         return 0;
56                 }
57
58                 public int GetHelpContext(out uint helpContext)
59                 {
60                         // not supported
61                         helpContext = 0;
62                         return 0;
63                 }
64                 #endregion
65         }
66 }
67
68 #endif