Exceptions

From Soldat Community Wiki
Revision as of 10:50, 15 August 2012 by Freeman (talk | contribs) (Created page with "<table> <tr style="font-weight: bold;"> <td>ExceptionType</td> <td>ExceptionParam</td> <td>ExceptionToString(ExceptionType, '$0')</td> </tr> <tr> <td>12</td> <td></td> <td>T...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
ExceptionType ExceptionParam ExceptionToString(ExceptionType, '$0')
12 Type Mismatch Bar {Type: variant} := Foo {Type: refer to Data Types, equivalent for all provided}
15 divide by Zero 0 / 0;
20 '$1' is not a valid integer value Exception: $0 StrtoInt('$1');
20 Nil interface Exception: $0 IDispatchInvoke(Foo {Type: variant or IDispatch}, false {or true}, 'Name', ['Par1', 'Par2']);
20 Invalid array Exception: $0 Bar {Type: variant} := Foo {Type: array[0..10] of string};
20 Could not convert variant of type (Null) into type (Integer) Exception: $0 Bar {Type: smallint} := Null;
20 Could not convert variant of type (Null) into type (Int64) Exception: $0 Bar {Type: boolean or byte} := Null;

 procedure ThrowException(const ExType: integer; const ExParam: string);
 var
   Vnt: variant;
 begin
   Vnt := ExType;
   RaiseException(Vnt, ExParam);
 end;
 procedure ActivateServer();
 var
   i: byte;
   Bar: variant;
 begin
   for i := 1 to 25 do begin
     WriteLn('<--- ' + InttoStr(i) + ' --->');
     try
       ThrowException(i, 'p' + InttoStr(i));
     except
       Bar := ExceptionType;
       WriteLn('ExceptionType=' + Bar);
       WriteLn('ExceptionParam=' + ExceptionParam);
       WriteLn('ExceptionToString(...)=' + ExceptionToString(ExceptionType, '$0'));
     end;
   end;
 end;

Results:

 <--- 1 --->
 ExceptionType=1
 ExceptionParam=p1
 ExceptionToString(...)=Cannot Import $0
 <--- 2 --->
 ExceptionType=2
 ExceptionParam=p2
 ExceptionToString(...)=Invalid Type
 <--- 3 --->
 ExceptionType=3
 ExceptionParam=p3
 ExceptionToString(...)=Internal error
 <--- 4 --->
 ExceptionType=4
 ExceptionParam=p4
 ExceptionToString(...)=Invalid Header
 <--- 5 --->
 ExceptionType=5
 ExceptionParam=p5
 ExceptionToString(...)=Invalid Opcode
 <--- 6 --->
 ExceptionType=6
 ExceptionParam=p6
 ExceptionToString(...)=Invalid Opcode Parameter
 <--- 7 --->
 ExceptionType=7
 ExceptionParam=p7
 ExceptionToString(...)=no Main Proc
 <--- 8 --->
 ExceptionType=8
 ExceptionParam=p8
 ExceptionToString(...)=Out of Global Vars range
 <--- 9 --->
 ExceptionType=9
 ExceptionParam=p9
 ExceptionToString(...)=Out of Proc Range
 <--- 10 --->
 ExceptionType=10
 ExceptionParam=p10
 ExceptionToString(...)=Out Of Range
 <--- 11 --->
 ExceptionType=11
 ExceptionParam=p11
 ExceptionToString(...)=Out Of Stack Range
 <--- 12 --->
 ExceptionType=12
 ExceptionParam=p12
 ExceptionToString(...)=Type Mismatch
 <--- 13 --->
 ExceptionType=13
 ExceptionParam=p13
 ExceptionToString(...)=Unexpected End Of File
 <--- 14 --->
 ExceptionType=14
 ExceptionParam=p14
 ExceptionToString(...)=Version error
 <--- 15 --->
 ExceptionType=15
 ExceptionParam=p15
 ExceptionToString(...)=divide by Zero
 <--- 16 --->
 ExceptionType=16
 ExceptionParam=p16
 ExceptionToString(...)=Math error
 <--- 17 --->
 ExceptionType=17
 ExceptionParam=p17
 ExceptionToString(...)=Could not call proc ($0)
 <--- 18 --->
 ExceptionType=18
 ExceptionParam=p18
 ExceptionToString(...)=Out of Record Fields Range
 <--- 19 --->
 ExceptionType=19
 ExceptionParam=p19
 ExceptionToString(...)=Out Of Memory
 <--- 20 --->
 ExceptionType=20
 ExceptionParam=p20
 ExceptionToString(...)=Exception: $0
 <--- 21 --->
 ExceptionType=21
 ExceptionParam=p21
 ExceptionToString(...)=Null Pointer Exception
 <--- 22 --->
 ExceptionType=22
 ExceptionParam=p22
 ExceptionToString(...)=Null variant error
 <--- 23 --->
 ExceptionType=23
 ExceptionParam=p23
 ExceptionToString(...)=Interface not supported
 <--- 24 --->
 ExceptionType=24
 ExceptionParam=p24
 ExceptionToString(...)=$0
 <--- 25 --->
 ExceptionType=25
 ExceptionParam=p25
 ExceptionToString(...)=Unknown error

Same results for 26-255 as 25; 0 has no exception thrown