[bcl] More netstandard api matching
[mono-project.git] / mcs / class / referencesource / mscorlib / system / runtime / interopservices / errorwrapper.cs
blob694412fd471faf0fd6eb03a415363e7e944e1393
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 /*=============================================================================
7 **
8 ** Class: ErrorWrapper.
9 **
11 ** Purpose: Wrapper that is converted to a variant with VT_ERROR.
14 =============================================================================*/
16 namespace System.Runtime.InteropServices {
18 using System;
19 using System.Security.Permissions;
21 [Serializable]
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);
46 public int ErrorCode
48 get
50 return m_ErrorCode;
54 private int m_ErrorCode;