Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.433 Beiträge
 
Delphi 7 Professional
 
#8

AW: Mögliche Exceptions eines Objektes herausfinden

  Alt 17. Apr 2020, 13:43
Bei meinem Delphi gibt es im BIN-Verzeichnis 'ne Grep.exe. Wenn ich die so aufrufe
Code:
c:\Delphi7\Bin>grep -dni except "e:\delphi\*.pas > grep.except.log"
gräbt die sich durch alle .pas-Dateien in dem Verzeichnis und raus kommt eine Datei in der alle Dateiname, die Zeilennummer und die Zeile stehen, in der die Zeichenfolge Except zu finden ist.

Das kann für eine Datei dann z. B. so aussehen:
Code:
File e:\delphi\PNG\pngimage.pas:
250         {Custom exception handler}
251         Exception = class(TObject)
254         ExceptClass = class of Exception;
259       EPNGOutMemory = class(Exception);
260       EPngError = class(Exception);
261       EPngUnexpectedEnd = class(Exception);
262       EPngInvalidCRC = class(Exception);
263       EPngInvalidIHDR = class(Exception);
264       EPNGMissingMultipleIDAT = class(Exception);
265       EPNGZLIBError = class(Exception);
266       EPNGInvalidPalette = class(Exception);
267       EPNGInvalidFileHeader = class(Exception);
268       EPNGIHDRNotFirst = class(Exception);
269       EPNGNotExists = class(Exception);
270       EPNGSizeExceeds = class(Exception);
271       EPNGMissingPalette = class(Exception);
272       EPNGUnknownCriticalChunk = class(Exception);
273       EPNGUnknownCompression = class(Exception);
274       EPNGUnknownInterlace = class(Exception);
275       EPNGNoImageData = class(Exception);
276       EPNGCouldNotLoadResource = class(Exception);
277       EPNGCannotChangeTransparent = class(Exception);
278       EPNGHeaderNotPresent = class(Exception);
279       EPNGInvalidNewSize = class(Exception);
280       EPNGInvalidSpec = class(Exception);
539         procedure RaiseError(ExceptionClass: ExceptClass; Text: String);
1163      {Exception implementation}
1164      constructor Exception.Create(Msg: String);
4565    procedure TPngObject.RaiseError(ExceptionClass: ExceptClass; Text: String);
4567      raise ExceptionClass.Create(Text);
5030        except
5143      except RaiseError(EPNGCouldNotLoadResource, EPNGCouldNotLoadResourceText);
5180                  else raise Exception.Create('');
5182              else raise Exception.Create('');
oder
Code:
c:\Delphi7\Bin>grep -dni class\(exception\) "e:\delphi\*.pas" >grep.class_Exception.log
ergibt
Code:
File e:\delphi\PNG\pngimage.pas:
259       EPNGOutMemory = class(Exception);
260       EPngError = class(Exception);
261       EPngUnexpectedEnd = class(Exception);
262       EPngInvalidCRC = class(Exception);
263       EPngInvalidIHDR = class(Exception);
264       EPNGMissingMultipleIDAT = class(Exception);
265       EPNGZLIBError = class(Exception);
266       EPNGInvalidPalette = class(Exception);
267       EPNGInvalidFileHeader = class(Exception);
268       EPNGIHDRNotFirst = class(Exception);
269       EPNGNotExists = class(Exception);
270       EPNGSizeExceeds = class(Exception);
271       EPNGMissingPalette = class(Exception);
272       EPNGUnknownCriticalChunk = class(Exception);
273       EPNGUnknownCompression = class(Exception);
274       EPNGUnknownInterlace = class(Exception);
275       EPNGNoImageData = class(Exception);
276       EPNGCouldNotLoadResource = class(Exception);
277       EPNGCannotChangeTransparent = class(Exception);
278       EPNGHeaderNotPresent = class(Exception);
279       EPNGInvalidNewSize = class(Exception);
280       EPNGInvalidSpec = class(Exception);
Und für den Sack Raise aus China
Code:
c:\Delphi7\Bin>grep -dni raise "e:\delphi\*.pas" >grep.raise.log
bekommen wir sowas:
Code:
File e:\delphi\PNG\pngimage.pas:
539         procedure RaiseError(ExceptionClass: ExceptClass; Text: String);
1625        fOwner.RaiseError(EPngError, EPNGCannotAddChunkText)
1630        fOwner.RaiseError(EPngError, EPNGCannotAddChunkText)
1634        fOwner.RaiseError(EPngError, EPNGCannotAddInvalidImageText)
1826        if ResID = 0 then raise EPNGError.Create('');
2014          Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText);
2242        Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
2276        Owner.RaiseError(EPNGInvalidIHDR, EPNGInvalidIHDRText);
2289        Owner.RaiseError(EPNGSizeExceeds, EPNGSizeExceedsText);
2296        Owner.RaiseError(EPNGUnknownCompression, EPNGUnknownCompressionText);
2303        Owner.RaiseError(EPNGUnknownInterlace, EPNGUnknownInterlaceText);
2593      if Size > 256 then Owner.RaiseError(EPNGInvalidPalette,
2680                Owner.RaiseError(EPNGInvalidCRC, EPNGInvalidCRCText);
2692              Owner.RaiseError(EPNGMissingMultipleIDAT, EPNGMissingMultipleIDATText);
2736            Owner.RaiseError(EPNGZLIBError,
3501          Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText);
4230      {Test if item is valid, if not raise error}
4232        Owner.RaiseError(EPNGError, EPNGUnknownPalEntryText)
4258        {Raise error}
4260        Owner.RaiseError(EPNGInvalidPalette, EPNGInvalidPaletteText);
4321        Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
4333        Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText);
4446        RaiseError(EPNGInvalidSpec, EInvalidSpec);
4564    {Raises an error}
4565    procedure TPngObject.RaiseError(ExceptionClass: ExceptClass; Text: String);
4567      raise ExceptionClass.Create(Text);
4621          {In case it does not exists, raise error}
4622          RaiseError(EPNGNotExists, EPNGNotExistsText);
4671        RaiseError(EPNGHeaderNotPresent, EPNGHeaderNotPresentText);
4766      if (BufferDC = 0) then RaiseError(EPNGOutMemory, EPNGOutMemoryText);
4774        RaiseError(EPNGOutMemory, EPNGOutMemoryText);
4966        RaiseError(EPNGInvalidFileHeader, EPNGInvalidFileHeaderText);
4988          RaiseError(EPNGUnexpectedEnd, EPNGUnexpectedEndText);
5000          RaiseError(EPNGIHDRNotFirst, EPNGIHDRNotFirstText);
5023            RaiseError(EPNGUnknownCriticalChunk, EPNGUnknownCriticalChunkText);
5032          raise;
5043        RaiseError(EPNGNoImageData, EPNGNoImageDataText);
5143      except RaiseError(EPNGCouldNotLoadResource, EPNGCouldNotLoadResourceText);
5180                  else raise Exception.Create('');
5182              else raise Exception.Create('');
5483        COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Self.RaiseError(
5696        RaiseError(EPNGInvalidNewSize, EInvalidNewSize)
Sollte für den Anfang und einen ersten Überblick sicherlich erstmal reichen

Ok: Bei den von Dir genannten Mengen an Zeilen und Exceptions wird es wohl erstmal sehr viel als Ergebnis geben, aber sicherlich besser als alles manuell durchsehen zu müssen.

Wird das zu Suchende in mehreren Dateien gefunden, so enthält die Ausgabe halt mehrere derartige Blöcke in der Reihenfolge des Findens der Dateien.

Hilfe zum Grep: http://docwiki.embarcadero.com/RADSt...search_utility
  Mit Zitat antworten Zitat