source: TFP-WebServer/SpaceWizards.HttpListener/src/System/Net/HttpListenerException.cs

Last change on this file was 377, checked in by alloc, 2 years ago

Made SpaceWizards.HttpListener compilable against .NET 4.8 with preprocessor define UNITY_NETFRAMEWORK

File size: 1.6 KB
Line 
1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3
4// ReSharper disable RedundantUsingDirective
5// ReSharper disable VirtualMemberCallInConstructor
6
7using System;
8using System.ComponentModel;
9using System.Net;
10using System.Runtime.InteropServices;
11using System.Runtime.Serialization;
12
13namespace SpaceWizards.HttpListener
14{
15 [Serializable]
16 public class HttpListenerException : Win32Exception
17 {
18#if !UNITY_NETFRAMEWORK
19 public HttpListenerException() : base(Marshal.GetLastPInvokeError())
20 {
21 if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}");
22 }
23#endif
24
25 public HttpListenerException(int errorCode) : base(errorCode)
26 {
27 if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}");
28 }
29
30 public HttpListenerException(int errorCode, string message) : base(errorCode, message)
31 {
32 if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}");
33 }
34
35 protected HttpListenerException(SerializationInfo serializationInfo, StreamingContext streamingContext)
36 : base(serializationInfo, streamingContext)
37 {
38 if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"{NativeErrorCode}:{Message}");
39 }
40
41 // the base class returns the HResult with this property
42 // we need the Win32 Error Code, hence the override.
43 public override int ErrorCode => NativeErrorCode;
44 }
45}
Note: See TracBrowser for help on using the repository browser.