unit uutlExceptions; { Package: Utils Prefix: utl - UTiLs Beschreibung: diese Unit enthält Definitionen für verschiedene Exceptions } {$mode objfpc}{$H+} interface uses Classes, SysUtils, syncobjs; type EOutOfRange = class(Exception) constructor Create(const aIndex, aMin, aMax: Integer); end; EUnknownType = class(Exception) public constructor Create(const aObj: TObject); end; EArgumentNil = class(Exception) public constructor Create(const aArgName: String); end; EArgument = class(Exception) public constructor Create(const aArg, aMsg: String); constructor Create(const aMsg: String); end; EParameter = EArgument; EFileDoesntExists = class(Exception) public constructor Create(const aFilename: string); end; EFileNotFound = EFileDoesntExists; EInvalidFile = class(Exception); EInvalidOperation = class(Exception); ENotSupported = class(Exception); EWait = class(Exception) private fWaitResult: TWaitResult; public property WaitResult: TWaitResult read fWaitResult; constructor Create(const msg: string; const aWaitResult: TWaitResult); end; implementation //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EOutOfRange.Create(const aIndex, aMin, aMax: Integer); begin inherited Create(format('index (%d) out of range (%d:%d)', [aIndex, aMin, aMax])); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EUnknownType.Create(const aObj: TObject); begin inherited Create(format('unknown type: %s', [aObj.ClassName])); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EArgumentNil.Create(const aArgName: String); begin inherited Create(format('argument ''%s'' can not be nil!', [aArgName])); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EArgument.Create(const aArg, aMsg: String); begin inherited Create(format('invalid argument "%s" - %s', [aArg, aMsg])) end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EArgument.Create(const aMsg: String); begin inherited Create(aMsg); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EFileDoesntExists.Create(const aFilename: string); begin inherited Create('file doesn''t exists: ' + aFilename); end; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// constructor EWait.Create(const msg: string; const aWaitResult: TWaitResult); begin inherited Create(msg); fWaitResult := aWaitResult; end; end.