3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 /*=============================================================================
8 ** Class: ErrorWrapper.
11 ** Purpose: Wrapper that is converted to a variant with VT_ERROR.
14 =============================================================================*/
16 namespace System.Runtime.InteropServices {
19 using System.Security.Permissions;
22 [System.Runtime.InteropServices.ComVisible(true)]
23 public sealed class ErrorWrapper
25 public ErrorWrapper(int errorCode)
27 m_ErrorCode = errorCode;
30 public ErrorWrapper(Object errorCode)
32 if (!(errorCode is int))
33 throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt32"), "errorCode");
34 m_ErrorCode = (int)errorCode;
37 [System.Security.SecuritySafeCritical] // auto-generated
38 #pragma warning disable 618
39 [SecurityPermissionAttribute(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)]
40 #pragma warning restore 618
41 public ErrorWrapper(Exception e)
43 m_ErrorCode = Marshal.GetHRForException(e);
54 private int m_ErrorCode;