errors.pp 1007 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY;without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. Unit errors;
  11. Interface
  12. uses unixtype;
  13. {$i errnostr.inc} // BSD or Linux ones
  14. Function StrError(err:cint):string;
  15. Procedure PError(const s:string; Errno : cint);
  16. Implementation
  17. Function StrError(err:cint):string;
  18. var s : string[12];
  19. begin
  20. if (err<0) or (err>=sys_errn) then
  21. begin
  22. str(err,s);
  23. StrError:='Unknown Error ('+s+')';
  24. end
  25. else
  26. StrError:=StrPas(Sys_ErrList[err]);
  27. end;
  28. procedure PError(const s:string; Errno : cint);
  29. begin
  30. WriteLn(stderr,s,': ',StrError(ErrNo));
  31. end;
  32. end.