delphi - How to return an error code with Halt(n) from an Exception block with D2007? -


Update : D is typical for 2007. It works in D-2010 as it works in the older version.

I would like to return an Except code, depending on the type of exception being caught in the handler block, in the exception of:

  Program testing; {$ APPTYPE console} uses SysUtils; Var Exitcode: integer; Start Writing ('Enter the error code:'); Readln (Exitcode); Try increasing EExternal.Create ('sdsdkfjh'); Except E: Start EExternal Writeln (E.Classname, ':', E.Message); Halt (Exitcode); End; End; End. Unfortunately in D200, the   Calling Halt (N) always gives exit code 1   from the exception block, whatever  

< Code> Process ExceptHandler (

ExceptObject: TObject; ExceptAddr: Pointer); away; Start ShowException (ExceptObject, ExceptAddr); Halt (1); // & lt; = @ # $ ## @ # $! End;

And no matter what the exhaust code I wanted, I get the code that is halts (1)

So the question This is that: / Strong>
How can I return only the desired exit code based on the exception?

Will this work?

  requires halts: = false; Try increasing EExternal.Create ('sdsdkfjh'); Except E: Start EExternal Writeln (E.Classname, ':', E.Message); NeedHalt: = True; End; End; If required Holt then (Exitcode);  

Or this?

Increase EExternal.Create ('sdsdkfjh'); Except E: Start EExternal Writeln (E.Classname, ':', E.Message); AcquireExceptionObject; Halt (Exitcode); End; End;

Anyway:.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -