IdException.pas 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.5 09/06/2004 09:52:52 CCostelloe
  18. Kylix 3 patch
  19. Rev 1.4 2004.04.18 4:38:24 PM czhower
  20. EIdExceptionBase created
  21. Rev 1.3 2004.03.07 11:45:22 AM czhower
  22. Flushbuffer fix + other minor ones found
  23. Rev 1.2 2/10/2004 7:33:24 PM JPMugaas
  24. I had to move the wrapper exception here for DotNET stack because Borland's
  25. update 1 does not permit unlisted units from being put into a package. That
  26. now would report an error and I didn't want to move IdExceptionCore into the
  27. System package.
  28. Rev 1.1 2004.02.03 3:15:52 PM czhower
  29. Updates to move to System.
  30. Rev 1.0 2004.02.03 2:36:00 PM czhower
  31. Move
  32. }
  33. unit IdException;
  34. interface
  35. {$I IdCompilerDefines.inc}
  36. uses
  37. SysUtils;
  38. type
  39. // EIdException is the base class for all Exceptions raised in the Indy library.
  40. EIdException = class(Exception)
  41. public
  42. {
  43. The constructor must be virtual for Delphi NET if you want to call it with class methods.
  44. Otherwise, it will not compile in that IDE. Also it's overloaded so that it doesn't close
  45. the other methods declared by the DotNet exception (particularly InnerException constructors)
  46. }
  47. constructor Create(const AMsg: string); overload; virtual;
  48. class procedure Toss(const AMsg: string); {$IFDEF HAS_DEPRECATED}deprecated{$IFDEF HAS_DEPRECATED_MSG} 'Use raise instead'{$ENDIF};{$ENDIF}
  49. end;
  50. TClassIdException = class of EIdException;
  51. // You can add EIdSilentException to the list of ignored exceptions to reduce debugger "trapping"
  52. // of "normal" exceptions
  53. EIdSilentException = class(EIdException);
  54. // EIdConnClosedGracefully is raised when remote side closes connection normally
  55. EIdConnClosedGracefully = class(EIdSilentException);
  56. {$IFDEF DOTNET}
  57. // This class used in DotNet. Under windows/linux, all errors that come out the
  58. // indy layer descend from IdException (actually not all errors in theory, but
  59. // certainly all errors in practice)
  60. // With DotNet, the socket library itself may raise various exceptions. If the
  61. // exception is a socket exception, then Indy will map this to an EIdSocketError.
  62. // Otherwise Indy will raise an EIdWrapperException. In this case, the original
  63. // exception will be available using the InnerException member
  64. EIdWrapperException = class (EIdException);
  65. {$ENDIF}
  66. //used for index out of range
  67. {CH EIdRangeException = class(EIdException); }
  68. // Other shared exceptions
  69. EIdSocketHandleError = class(EIdException);
  70. {$IFDEF UNIX}
  71. EIdNonBlockingNotSupported = class(EIdException);
  72. {$ENDIF}
  73. EIdPackageSizeTooBig = class(EIdSocketHandleError);
  74. EIdNotAllBytesSent = class (EIdSocketHandleError);
  75. EIdCouldNotBindSocket = class (EIdSocketHandleError);
  76. EIdCanNotBindPortInRange = class (EIdSocketHandleError);
  77. EIdInvalidPortRange = class(EIdSocketHandleError);
  78. EIdCannotSetIPVersionWhenConnected = class(EIdSocketHandleError);
  79. {CH EIdInvalidIPAddress = class(EIdSocketHandleError); }
  80. implementation
  81. { EIdException }
  82. constructor EIdException.Create(const AMsg : String);
  83. begin
  84. inherited Create(AMsg);
  85. end;
  86. {$I IdDeprecatedImplBugOff.inc}
  87. class procedure EIdException.Toss(const AMsg: string);
  88. {$I IdDeprecatedImplBugOn.inc}
  89. begin
  90. raise Create(AMsg);
  91. end;
  92. end.