25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

104 satır
3.2 KiB

  1. unit uutlExceptions;
  2. { Package: Utils
  3. Prefix: utl - UTiLs
  4. Beschreibung: diese Unit enthält Definitionen für verschiedene Exceptions }
  5. {$mode objfpc}{$H+}
  6. interface
  7. uses
  8. Classes, SysUtils, syncobjs;
  9. type
  10. EOutOfRange = class(Exception)
  11. constructor Create(const aIndex, aMin, aMax: Integer);
  12. end;
  13. EUnknownType = class(Exception)
  14. public
  15. constructor Create(const aObj: TObject);
  16. end;
  17. EArgumentNil = class(Exception)
  18. public
  19. constructor Create(const aArgName: String);
  20. end;
  21. EArgument = class(Exception)
  22. public
  23. constructor Create(const aArg, aMsg: String);
  24. constructor Create(const aMsg: String);
  25. end;
  26. EParameter = EArgument;
  27. EFileDoesntExists = class(Exception)
  28. public
  29. constructor Create(const aFilename: string);
  30. end;
  31. EFileNotFound = EFileDoesntExists;
  32. EInvalidFile = class(Exception);
  33. EInvalidOperation = class(Exception);
  34. ENotSupported = class(Exception);
  35. EWait = class(Exception)
  36. private
  37. fWaitResult: TWaitResult;
  38. public
  39. property WaitResult: TWaitResult read fWaitResult;
  40. constructor Create(const msg: string; const aWaitResult: TWaitResult);
  41. end;
  42. implementation
  43. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. constructor EOutOfRange.Create(const aIndex, aMin, aMax: Integer);
  45. begin
  46. inherited Create(format('index (%d) out of range (%d:%d)', [aIndex, aMin, aMax]));
  47. end;
  48. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  49. constructor EUnknownType.Create(const aObj: TObject);
  50. begin
  51. inherited Create(format('unknown type: %s', [aObj.ClassName]));
  52. end;
  53. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  54. constructor EArgumentNil.Create(const aArgName: String);
  55. begin
  56. inherited Create(format('argument ''%s'' can not be nil!', [aArgName]));
  57. end;
  58. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  59. constructor EArgument.Create(const aArg, aMsg: String);
  60. begin
  61. inherited Create(format('invalid argument "%s" - %s', [aArg, aMsg]))
  62. end;
  63. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  64. constructor EArgument.Create(const aMsg: String);
  65. begin
  66. inherited Create(aMsg);
  67. end;
  68. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  69. constructor EFileDoesntExists.Create(const aFilename: string);
  70. begin
  71. inherited Create('file doesn''t exists: ' + aFilename);
  72. end;
  73. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  74. constructor EWait.Create(const msg: string; const aWaitResult: TWaitResult);
  75. begin
  76. inherited Create(msg);
  77. fWaitResult := aWaitResult;
  78. end;
  79. end.