[fpc-devel]Minor differences with Delphi

Johannes Berg johannes at sipsolutions.de
Sat Nov 8 12:41:25 CET 2003


On Fri, 2003-11-07 at 12:55, David Butler wrote:
> Sorry, I should have guessed. Yes, it basically takes the OS error and
> raises some exception. The exception message is the OS error message
> as returned by an OS function call.

Here's a basic implementation that works for me (*):

const
  StrOSError : string = 'System error (number %d).'+LineEnding+'%s';
                                                                                
type
  EOSError = class(Exception)
  end;

procedure RaiseLastOSError;
var
  LError: integer;
begin
  LError := GetLastError;
  raise EOSError.CreateFmt(StrOSError,[LError,StrError(LError)]);
end;

(*) for linux, GetLastError is not defined in system.pp. It should be
(to be Delphi compatible), and this works:

function GetLastError: Integer;
begin
  Result := fpGetErrno;
end;

johannes
-- 
http://www.sipsolutions.de/
GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc
  Key-ID: 9AB78CA5 Johannes Berg <johannes at sipsolutions.de>
  Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20031108/200e2e77/attachment.sig>


More information about the fpc-devel mailing list