Difference between revisions of "Exceptions"

From Soldat Community Wiki
Jump to: navigation, search
(Enumerated values)
m (Enumerated values)
 
Line 201: Line 201:
 
<li>ErCannotImport
 
<li>ErCannotImport
 
<li>ErInvalidType
 
<li>ErInvalidType
<li>ErInt<li>ErnalError
+
<li>ErInternalError
 
<li>ErInvalidHeader
 
<li>ErInvalidHeader
 
<li>ErInvalidOpcode
 
<li>ErInvalidOpcode

Latest revision as of 00:01, 1 June 2014

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

Enumerated values

http://www.be-precision.com/products/precision-builder/express/webhelp/en/topics/PSSyntax.htm

 TIFException = (ErNoError, erCannotImport, erInvalidType, ErInternalError, erInvalidHeader, erInvalidOpcode, erInvalidOpcodeParameter, erNoMainProc, erOutOfGlobalVarsRange, erOutOfProcRange, ErOutOfRange, erOutOfStackRange, ErTypeMismatch, erUnexpectedEof, erVersionError, ErDivideByZero, ErMathError,erCouldNotCallProc, erOutofRecordRange, erOutOfMemory, erException, erNullPointerException, erNullVariantError, erInterfaceNotSupported, erCustomError)

TIFException appears to be an enumeration of the following, with specified numeric equivalents. These should all be defined (but only the first few were tested):

  1. ErNoError
  2. ErCannotImport
  3. ErInvalidType
  4. ErInternalError
  5. ErInvalidHeader
  6. ErInvalidOpcode
  7. ErInvalidOpcodeParameter
  8. ErNoMainProc
  9. ErOutOfGlobalVarsRange
  10. ErOutOfProcRange
  11. ErOutOfRange
  12. ErOutOfStackRange
  13. ErTypeMismatch
  14. ErUnexpectedEof
  15. ErVersionError
  16. ErDivideByZero
  17. ErMathError
  18. ErCouldNotCallProc
  19. ErOutofRecordRange
  20. ErOutOfMemory
  21. ErException
  22. ErNullPointerException
  23. ErNullVariantError
  24. ErInterfaceNotSupported
  25. ErCustomError