Merge pull request #1695 from gregoryyoung/master
[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 using System;
7 using System.Runtime.CompilerServices;
8 using System.Security;
9
10 namespace System.Runtime.InteropServices
11 {
12         /// <summary>
13         /// Helper class that allows to pass an exception as an IErrorInfo object. This is useful
14         /// when we get an exception in managed code that is called from unmanaged code that is called
15         /// from managed code and we want to get to the exception in the outer managed code.
16         /// </summary>
17         internal class ManagedErrorInfo: IErrorInfo
18         {
19                 private Exception m_Exception;
20                 public ManagedErrorInfo (Exception e)
21                 {
22                         m_Exception = e;
23                 }
24
25                 public Exception Exception {
26                         get { return m_Exception; }
27                 }
28
29                 #region IErrorInfo
30                 public int GetGUID (out Guid guid)
31                 {
32                         // not supported
33                         guid = Guid.Empty;
34                         return 0;
35                 }
36
37                 public int GetSource (out string source)
38                 {
39                         source = m_Exception.Source;
40                         return 0;
41                 }
42
43                 public int GetDescription (out string description)
44                 {
45                         description = m_Exception.Message;
46                         return 0;
47                 }
48
49                 public int GetHelpFile (out string helpFile)
50                 {
51                         helpFile = m_Exception.HelpLink;
52                         return 0;
53                 }
54
55                 public int GetHelpContext(out uint helpContext)
56                 {
57                         // not supported
58                         helpContext = 0;
59                         return 0;
60                 }
61                 #endregion
62         }
63 }