| QkExceptions.pas Updated 01 Aug 2020 | Upper levels: - QuArK Information Base - 4. The Source Code - 4.5. File-by-file descriptions

4.5.6. QkExceptions.pas | [ Prev - Up - Next ]

This file contains several functions useful for exception handling.

Index

- - GetExceptionMessage (05 Apr 2018)
- - LogAndWarn (05 Apr 2018)
- - LogAndRaiseError (05 Apr 2018)
- - EError (05 Apr 2018)
- - EErrorFmt (05 Apr 2018)
- - InternalE (05 Apr 2018)
- - GlobalWarning (05 Apr 2018)
- - GlobalDisplayWarnings (05 Apr 2018)
- - GetSystemErrorMessage (01 Aug 2020)
- - LogWindowsError (05 Apr 2018)

GetExceptionMessage | DanielPharos - 05 Apr 2018 | [ Top ]

    function GetExceptionMessage(E: Exception) : String;
This function takes a generated exception, and strips the additional information from it and adds a point to the end ( `.` ). The additional information is everything after a double slash ( `//` ), and is used by the exception handler for the MORE panel. This function should be used instead of `E.message` whenever possible.

LogAndWarn | DanielPharos - 05 Apr 2018 | [ Top ]

    procedure LogAndWarn(const WarnMessage : String);
Logs the error message given by `ErrMessage` to the log with LOG_WARNING priority, and then pops up a dialogbox with `ErrMessage` as the message. Note: This never raises any errors (by default...), so the code WILL return!

LogAndRaiseError | DanielPharos - 05 Apr 2018 | [ Top ]

    procedure LogAndRaiseError(const ErrMessage : String);
Logs the error message given by `ErrMessage` to the log with LOG_CRITICAL priority, and then raises a Delphi exception with `ErrMessage` as the message. Note: Since this raises an error, the code will NOT return!

EError | DanielPharos - 05 Apr 2018 | [ Top ]

    function EError(Res: Integer) : Exception;
This function takes the number of a string from the dictionary, and creates an exception with the resulting text as the message.

EErrorFmt | DanielPharos - 05 Apr 2018 | [ Top ]

    function EErrorFmt(Res: Integer; Fmt: array of const) : Exception;
This function takes the number of a string from the dictionary, formats that string using the array of variables and values from the second parameter, and creates an exception with the resulting text as the message.

InternalE | DanielPharos - 05 Apr 2018 | [ Top ]

    function InternalE(const Hint: String) : Exception;
This function takes the hint and constructs a 'this program is buggy' message. Use this if the error can only happen if the program somehow managed to do something that *should* be impossible.

GlobalWarning | DanielPharos - 05 Apr 2018 | [ Top ]

    procedure GlobalWarning(const Texte: String);
Adds `Texte` to the list of global warnings. Use this for instance during loading of a file, so all warnings can be displayed at once when loading has been completed.

GlobalDisplayWarnings | DanielPharos - 05 Apr 2018 | [ Top ]

    procedure GlobalDisplayWarnings;
Displays and clears all global warnings. This is called from AppIdle, so there (normally) is no need to call it yourself.

GetSystemErrorMessage | DanielPharos - 01 Aug 2020 | [ Top ]

    function GetSystemErrorMessage(ErrNr: DWORD) : String;
Retrieves the text associated with a Windows error number. This can be used in conjunction with `GetLastError` directly after a Windows exception has occurred.

LogWindowsError | DanielPharos - 05 Apr 2018 | [ Top ]

    procedure LogWindowsError(ErrNr: DWORD; const Call: String);
Use this if a Windows API fails. This procedure logs the error message given by `GetSystemErrorMessage(ErrNr)` to the log with LOG_WARNING priority, and blaims the `Call` function call for producing it. Note: This never raises any errors (by default...), so the code WILL return!

Copyright (c) 2021, GNU General Public License by The QuArK (Quake Army Knife) Community - http://quark.sourceforge.net/ | [ Prev - Top - Next ]