errori.inc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2006 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. Constructor TPTCError.Create;
  18. Begin
  19. FMessage := '';
  20. End;
  21. Constructor TPTCError.Create(Const AMessage : String);
  22. Begin
  23. FMessage := AMessage;
  24. LOG('error', Self);
  25. End;
  26. Constructor TPTCError.Create(Const AMessage : String; Const AError : TPTCError);
  27. Begin
  28. FMessage := AMessage + #10 + AError.FMessage;
  29. LOG('composite error', Self);
  30. End;
  31. Constructor TPTCError.Create(Const AError : TPTCError);
  32. Begin
  33. FMessage := AError.FMessage;
  34. End;
  35. Destructor TPTCError.Destroy;
  36. Begin
  37. Inherited Destroy;
  38. End;
  39. Procedure TPTCError.Assign(Const AError : TPTCError);
  40. Begin
  41. FMessage := AError.FMessage;
  42. End;
  43. Function TPTCError.Equals(Const AError : TPTCError) : Boolean;
  44. Begin
  45. Equals := (FMessage = AError.FMessage);
  46. End;
  47. Procedure TPTCError.Report;
  48. {$IFDEF Win32}
  49. Var
  50. txt : AnsiString;
  51. {$ENDIF Win32}
  52. {$IFDEF WinCE}
  53. Var
  54. txt : WideString;
  55. {$ENDIF WinCE}
  56. Begin
  57. LOG('error report', Self);
  58. {$IFDEF GO32V2}
  59. RestoreTextMode;
  60. Writeln(stderr, 'error: ', FMessage);
  61. {$ENDIF GO32V2}
  62. {$IFDEF Win32}
  63. Win32Cursor_resurrect;
  64. txt := FMessage;
  65. MessageBox(0, PChar(txt), 'Error', MB_OK Or MB_ICONERROR Or MB_SETFOREGROUND Or MB_TOPMOST);
  66. {$ENDIF Win32}
  67. {$IFDEF WinCE}
  68. txt := FMessage;
  69. MessageBox(0, PWideChar(txt), 'Error', MB_OK Or MB_ICONERROR Or MB_SETFOREGROUND Or MB_TOPMOST);
  70. {$ENDIF WinCE}
  71. {$IFDEF UNIX}
  72. Writeln(stderr, 'error: ', FMessage);
  73. {$ENDIF UNIX}
  74. Halt(1);
  75. End;