Declared in: UErrorCodes
TAppError is a value type (record) that carries a
structured error: an EC_* code, a
human-readable message, and optionally a native engine error number and
message from MySQL/MariaDB or ElevateDB.
It is the type of the LastError property on TMMScript, TMMUpdater, and
TMMHttpClient.
A default-initialised TAppError
(Code = 0 = EC_NONE) represents the absence of an
error.
Use IsError rather than comparing Code to zero
directly.
TAppError = record
Code : Integer; // EC_* error code; 0 (EC_NONE) = no error
Msg : string; // human-readable description; '' = no error
NativeCode: Integer; // raw engine error number; 0 = not applicable
NativeMsg : string; // raw engine error message; '' = not applicable
function IsError: Boolean;
// Internal constructors (used by the library):
class function Make(...): TAppError; static;
class function MakeFmt(...): TAppError; static;
class function FromException(...): TAppError; static;
end;
| Field | Description |
|---|---|
Code |
EC_* error code.
0 = EC_NONE = no error. |
Msg |
Human-readable description. Empty when
Code = EC_NONE. |
NativeCode |
Raw MySQL or EDB engine error number when a server-side or engine
error is the root cause — the /N<number> suffix shown
in the application log. 0 when not applicable. |
NativeMsg |
Original engine error message from the PDO or EDB driver. Empty when not applicable. |
function IsError: Boolean;
Returns True when Code <> EC_NONE.
Prefer this over comparing Code to zero directly, since
EC_NONE = 0 may not be obvious to future readers.
These constructors are used internally by the library to build
TAppErrorvalues. You do not normally need to call them directly.
Make builds a TAppError from an explicit
code and message string. MakeFmt applies Args
to the standard EM_* message template for
ACode. FromException builds from a caught
exception, setting Msg to E.Message.
EAppError is an exception class that wraps a
TAppError. It is raised when a structured error must
propagate across call boundaries. Exception.Message mirrors
Error.Msg.
EAppError = class(Exception)
constructor Create(const AError: TAppError); overload;
constructor CreateCode(ACode: Integer; const AMsg: string;
ANativeCode: Integer = 0; const ANativeMsg: string = ''); overload;
property Error: TAppError read FError;
end;
EAppError is not raised by
TMMScript.Execute or TMMUpdater.Execute —
those report errors through Success,
LastError.Msg, and LastError properties. It
may be raised by lower-level operations inside the pipeline. Catch it
when you call lower-level entry points directly, or let it propagate and
handle it at a higher level.
try
Script.Execute;
except
on E: EAppError do
ShowMessage(Format('[E%d] %s', [E.Error.Code, E.Error.Msg]));
end;
TAppError is visible through EDBMMClient
without an explicit uses entry. Add
UErrorCodes only when your code compares
LastError.Code against EC_* constants
directly:
uses EDBMMClient, UErrorCodes; // UErrorCodes needed for EC_* constants
Script.Execute;
if Script.LastError.IsError then
begin
if Script.LastError.Code = EC_HTTP_TIMEOUT then
ShowMessage('Query timed out — add a LIMIT clause or increase server timeouts')
else
ShowMessage(Script.LastError.Msg);
end;