-
Notifications
You must be signed in to change notification settings - Fork 1
/
RpcbErr.pas
186 lines (171 loc) · 6.88 KB
/
RpcbErr.pas
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
{ **************************************************************
Package: XWB - Kernel RPCBroker
Date Created: Sept 18, 1997 (Version 1.1)
Site Name: Oakland, OI Field Office, Dept of Veteran Affairs
Developers: Danila Manapsal, Don Craven, Joel Ivey
Description: Error handling for TRPCBroker.
Current Release: Version 1.1 Patch 40 (January 7, 2005))
*************************************************************** }
unit Rpcberr;
interface
uses
TRPCB, Winsock, Classes, Forms, SysUtils, Controls,
StdCtrls, Buttons, ExtCtrls, Graphics, WinProcs;
type
TfrmRpcbError = class(TForm)
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
Label1: TLabel;
Bevel1: TBevel;
Symbol: TImage;
Label2: TLabel;
Label3: TLabel;
lblAction: TLabel;
lblCode: TLabel;
lblMessage: TLabel;
procedure FormCreate(Sender: TObject);
end;
var
frmRpcbError: TfrmRpcbError;
procedure ShowBrokerError(BrokerError: EBrokerError);
procedure NetError(Action: string; ErrType: integer);
const
XWBBASEERR = {WSABASEERR + 1} 20000;
{Broker Application Error Constants}
XWB_NO_HEAP = XWBBASEERR + 1;
XWB_M_REJECT = XWBBASEERR + 2;
XWB_BadSignOn = XWBBASEERR + 4;
XWB_BldConnectList = XWBBASEERR + 5;
XWB_NullRpcVer = XWBBASEERR + 6;
XWB_ExeNoMem = XWBBASEERR + 100;
XWB_ExeNoFile = XWB_ExeNoMem + 2;
XWB_ExeNoPath = XWB_ExeNoMem + 3;
XWB_ExeShare = XWB_ExeNoMem + 5;
XWB_ExeSepSeg = XWB_ExeNoMem + 6;
XWB_ExeLoMem = XWB_ExeNoMem + 8;
XWB_ExeWinVer = XWB_ExeNoMem + 10;
XWB_ExeBadExe = XWB_ExeNoMem + 11;
XWB_ExeDifOS = XWB_ExeNoMem + 12;
XWB_RpcNotReg = XWBBASEERR + 201;
implementation
uses wsockc;
{$R *.DFM}
procedure ShowBrokerError(BrokerError: EBrokerError);
begin
try
Application.CreateForm(TfrmRpcbError, frmRpcbError);
with frmRpcbError do begin
lblAction.Caption := BrokerError.Action;
lblCode.Caption := IntToStr(BrokerError.Code);
lblMessage.Caption := BrokerError.Mnemonic;
ShowModal;
end
finally
frmRpcbError.Release;
end;
end;
procedure TfrmRpcbError.FormCreate(Sender: TObject);
var
FIcon: TIcon;
begin
FIcon := TIcon.Create;
try
FIcon.Handle := LoadIcon(0, IDI_HAND);
Symbol.Picture.Graphic := FIcon;
Symbol.BoundsRect := Bounds(Symbol.Left, Symbol.Top, FIcon.Width, FIcon.Height);
finally
FIcon.Free;
end;
end;
procedure NetError(Action : String; ErrType: integer);
var
x,s: string;
r: integer;
BrokerError: EBrokerError;
begin
Screen.Cursor := crDefault;
r := 0;
if ErrType > 0 then r := ErrType;
if ErrType = 0 then
begin
r := WSAGetLastError;
// if r = WSAEINTR then xFlush := True;
// if WSAIsBlocking = True then WSACancelBlockingCall;
end;
Case r of
WSAEINTR : x := 'WSAEINTR';
WSAEBADF : x := 'WSAEINTR';
WSAEFAULT : x := 'WSAEFAULT';
WSAEINVAL : x := 'WSAEINVAL';
WSAEMFILE : x := 'WSAEMFILE';
WSAEWOULDBLOCK : x := 'WSAEWOULDBLOCK';
WSAEINPROGRESS : x := 'WSAEINPROGRESS';
WSAEALREADY : x := 'WSAEALREADY';
WSAENOTSOCK : x := 'WSAENOTSOCK';
WSAEDESTADDRREQ : x := 'WSAEDESTADDRREQ';
WSAEMSGSIZE : x := 'WSAEMSGSIZE';
WSAEPROTOTYPE : x := 'WSAEPROTOTYPE';
WSAENOPROTOOPT : x := 'WSAENOPROTOOPT';
WSAEPROTONOSUPPORT : x := 'WSAEPROTONOSUPPORT';
WSAESOCKTNOSUPPORT : x := 'WSAESOCKTNOSUPPORT';
WSAEOPNOTSUPP : x := 'WSAEOPNOTSUPP';
WSAEPFNOSUPPORT : x := 'WSAEPFNOSUPPORT';
WSAEAFNOSUPPORT : x := 'WSAEAFNOSUPPORT';
WSAEADDRINUSE : x := 'WSAEADDRINUSE';
WSAEADDRNOTAVAIL : x := 'WSAEADDRNOTAVAIL';
WSAENETDOWN : x := 'WSAENETDOWN';
WSAENETUNREACH : x := 'WSAENETUNREACH';
WSAENETRESET : x := 'WSAENETRESET';
WSAECONNABORTED : x := 'WSAECONNABORTED';
WSAECONNRESET : x := 'WSAECONNRESET';
WSAENOBUFS : x := 'WSAENOBUFS';
WSAEISCONN : x := 'WSAEISCONN';
WSAENOTCONN : x := 'WSAENOTCONN';
WSAESHUTDOWN : x := 'WSAESHUTDOWN';
WSAETOOMANYREFS : x := 'WSAETOOMANYREFS';
WSAETIMEDOUT : x := 'WSAETIMEDOUT';
WSAECONNREFUSED : x := 'WSAECONNREFUSED';
WSAELOOP : x := 'WSAELOOP';
WSAENAMETOOLONG : x := 'WSAENAMETOOLONG';
WSAEHOSTDOWN : x := 'WSAEHOSTDOWN';
WSAEHOSTUNREACH : x := 'WSAEHOSTUNREACH';
WSAENOTEMPTY : x := 'WSAENOTEMPTY';
WSAEPROCLIM : x := 'WSAEPROCLIM';
WSAEUSERS : x := 'WSAEUSERS';
WSAEDQUOT : x := 'WSAEDQUOT';
WSAESTALE : x := 'WSAESTALE';
WSAEREMOTE : x := 'WSAEREMOTE';
WSASYSNOTREADY : x := 'WSASYSNOTREADY';
WSAVERNOTSUPPORTED : x := 'WSAVERNOTSUPPORTED';
WSANOTINITIALISED : x := 'WSANOTINITIALISED';
WSAHOST_NOT_FOUND : x := 'WSAHOST_NOT_FOUND';
WSATRY_AGAIN : x := 'WSATRY_AGAIN';
WSANO_RECOVERY : x := 'WSANO_RECOVERY';
WSANO_DATA : x := 'WSANO_DATA';
XWB_NO_HEAP : x := 'Insufficient Heap';
XWB_M_REJECT : x := 'M Error - Use ^XTER';
XWB_BadSignOn : x := 'Sign-on was not completed.';
XWB_ExeNoMem : x := 'System was out of memory, executable file was corrupt, or relocations were invalid.';
XWB_ExeNoFile : x := 'File was not found.';
XWB_ExeNoPath : x := 'Path was not found.';
XWB_ExeShare : x := 'Attempt was made to dynamically link to a task,' +
' or there was a sharing or network-protection error.';
XWB_ExeSepSeg : x := 'Library required separate data segments for each task.';
XWB_ExeLoMem : x := 'There was insufficient memory to start the application.';
XWB_ExeWinVer : x := 'Windows version was incorrect.';
XWB_ExeBadExe : x := 'Executable file was invalid.' +
' Either it was not a Windows application or there was an error in the .EXE image.';
XWB_ExeDifOS : x := 'Application was designed for a different operating system.';
XWB_RpcNotReg : X := 'Remote procedure not registered to application.';
XWB_BldConnectList : x := 'BrokerConnections list could not be created';
XWB_NullRpcVer : x := 'RpcVersion cannot be empty.' + #13 + 'Default is 0 (zero).';
else x := IntToStr(r);
end;
s := 'Error encountered.' + chr(13)+chr(10) + 'Function was: ' + Action + chr(13)+chr(10) + 'Error was: ' + x;
BrokerError := EBrokerError.Create(s);
BrokerError.Action := Action;
BrokerError.Code := r;
BrokerError.Mnemonic := x;
raise BrokerError;
end;
end.