errori.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. Procedure TPTCError.defaults;
  18. Begin
  19. Fmessage := '';
  20. End;
  21. Constructor TPTCError.Create;
  22. Begin
  23. defaults;
  24. End;
  25. Constructor TPTCError.Create(Const _message : String);
  26. Begin
  27. Fmessage := _message;
  28. LOG('error', Self);
  29. End;
  30. Constructor TPTCError.Create(Const _message : String; Const error : TPTCError);
  31. Begin
  32. Fmessage := _message + #13 + #10 + error.Fmessage;
  33. LOG('composite error', Self);
  34. End;
  35. Constructor TPTCError.Create(Const error : TPTCError);
  36. Begin
  37. defaults;
  38. ASSign(error);
  39. End;
  40. Destructor TPTCError.Destroy;
  41. Begin
  42. Inherited Destroy;
  43. End;
  44. Procedure TPTCError.Assign(Const error : TPTCError);
  45. Begin
  46. If Self = error Then
  47. Raise TPTCError.Create('self assignment is not allowed');
  48. Fmessage := error.Fmessage;
  49. End;
  50. Function TPTCError.Equals(Const error : TPTCError) : Boolean;
  51. Begin
  52. Equals := (Fmessage = error.Fmessage);
  53. End;
  54. Procedure TPTCError.report;
  55. {$IFDEF WIN32}
  56. Var
  57. txt : ShortString;
  58. {$ENDIF WIN32}
  59. Begin
  60. LOG('error report', Self);
  61. {$IFDEF GO32V2}
  62. RestoreTextMode;
  63. Writeln(stderr, Fmessage);
  64. {$ENDIF GO32V2}
  65. {$IFDEF WIN32}
  66. Win32Cursor_resurrect;
  67. txt := Fmessage + #0;
  68. MessageBox(0, @txt[1], 'Error', MB_OK Or MB_ICONERROR Or MB_SETFOREGROUND Or MB_TOPMOST);
  69. {$ENDIF WIN32}
  70. {$IFDEF UNIX}
  71. Writeln(stderr, 'error: ', Fmessage);
  72. {$ENDIF UNIX}
  73. Halt(1);
  74. End;
  75. Function TPTCError.message : String;
  76. Begin
  77. message := Fmessage;
  78. End;