1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//
// System.ComponentModel.Win32Exceptioncs
//
// Author:
// Dick Porter (dick@ximian.com)
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
//
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Collections;
using System.Globalization;
namespace System.ComponentModel
{
[Serializable]
public class Win32Exception : ExternalException
{
private int native_error_code;
public Win32Exception ()
: base (W32ErrorMessage(Marshal.GetLastWin32Error()),
Marshal.GetLastWin32Error()) {
native_error_code=Marshal.GetLastWin32Error();
}
public Win32Exception(int error)
: base (W32ErrorMessage(error), error) {
native_error_code=error;
}
public Win32Exception(int error, string message)
: base (message, error) {
native_error_code=error;
}
protected Win32Exception(SerializationInfo info,
StreamingContext context)
: base (info, context) {
}
public int NativeErrorCode {
get {
return(native_error_code);
}
}
[MonoTODO]
public override void GetObjectData(SerializationInfo info,
StreamingContext context) {
if(info==null) {
throw new ArgumentNullException();
}
throw new NotImplementedException();
}
private static Hashtable w32_errors = new Hashtable();
/* Initialise the list of error strings */
static Win32Exception() {
/* No need to list everything, just the ones
* the runtime can throw. A list of the errors
* can be found in class System.IO.MonoIOError.
*/
w32_errors.Add(11001,
Locale.GetText("No such host is known"));
w32_errors.Add(10047,
Locale.GetText("AF not supported"));
w32_errors.Add(10043,
Locale.GetText("proto no supported"));
w32_errors.Add(10044,
Locale.GetText("socket not supproted"));
w32_errors.Add(10004,
Locale.GetText("interrupted"));
w32_errors.Add(10013,
Locale.GetText("Access denied"));
w32_errors.Add(11002,
Locale.GetText("A temporary error occurred on an authoritative name server. Try again later."));
w32_errors.Add(10022,
Locale.GetText("Invalid arguments"));
w32_errors.Add(10050,
Locale.GetText("Network subsystem is down"));
w32_errors.Add(10051,
Locale.GetText("Network is unreachable"));
w32_errors.Add(10061,
Locale.GetText("Connection refused"));
w32_errors.Add(10045,
Locale.GetText("Operation not supported"));
w32_errors.Add(10038,
Locale.GetText("The descriptor is not a socket"));
w32_errors.Add(10055,
Locale.GetText("Not enough buffer space is available"));
w32_errors.Add(10056,
Locale.GetText("Socket is already connected"));
w32_errors.Add(10048,
Locale.GetText("Address already in use"));
w32_errors.Add(10057,
Locale.GetText("The socket is not connected"));
w32_errors.Add(10058,
Locale.GetText("The socket has been shut down"));
w32_errors.Add(10093,
Locale.GetText("Winsock not initialized"));
}
private static string W32ErrorMessage(int error_code) {
string message=(string)w32_errors[error_code];
if(message==null) {
return(Locale.GetText("Some sort of w32 error occurred"));
} else {
return(message);
}
}
}
}
|