hedgewars/uDebug.pas
author nemo
Fri, 24 Dec 2010 16:24:30 -0500
changeset 4670 f06c30d0b64c
parent 4403 0dfe26f48ec1
child 4900 8ad0e23e6d63
permissions -rw-r--r--
oops
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4403
unc0rr
parents:
diff changeset
     1
{$INCLUDE "options.inc"}
unc0rr
parents:
diff changeset
     2
unc0rr
parents:
diff changeset
     3
unit uDebug;
unc0rr
parents:
diff changeset
     4
unc0rr
parents:
diff changeset
     5
interface
unc0rr
parents:
diff changeset
     6
unc0rr
parents:
diff changeset
     7
procedure OutError(Msg: shortstring; isFatalError: boolean);
unc0rr
parents:
diff changeset
     8
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
unc0rr
parents:
diff changeset
     9
procedure SDLTry(Assert: boolean; isFatal: boolean);
unc0rr
parents:
diff changeset
    10
unc0rr
parents:
diff changeset
    11
implementation
unc0rr
parents:
diff changeset
    12
uses SDLh, uConsole, uCommands;
unc0rr
parents:
diff changeset
    13
unc0rr
parents:
diff changeset
    14
procedure OutError(Msg: shortstring; isFatalError: boolean);
unc0rr
parents:
diff changeset
    15
begin
unc0rr
parents:
diff changeset
    16
WriteLnToConsole(Msg);
unc0rr
parents:
diff changeset
    17
if isFatalError then
unc0rr
parents:
diff changeset
    18
    begin
unc0rr
parents:
diff changeset
    19
    ParseCommand('fatal ' + GetLastConsoleLine, true);
unc0rr
parents:
diff changeset
    20
    SDL_Quit;
unc0rr
parents:
diff changeset
    21
    halt(1)
unc0rr
parents:
diff changeset
    22
    end
unc0rr
parents:
diff changeset
    23
end;
unc0rr
parents:
diff changeset
    24
unc0rr
parents:
diff changeset
    25
procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
unc0rr
parents:
diff changeset
    26
begin
unc0rr
parents:
diff changeset
    27
if not Assert then OutError(Msg, isFatal)
unc0rr
parents:
diff changeset
    28
end;
unc0rr
parents:
diff changeset
    29
unc0rr
parents:
diff changeset
    30
procedure SDLTry(Assert: boolean; isFatal: boolean);
unc0rr
parents:
diff changeset
    31
begin
unc0rr
parents:
diff changeset
    32
if not Assert then OutError(SDL_GetError, isFatal)
unc0rr
parents:
diff changeset
    33
end;
unc0rr
parents:
diff changeset
    34
unc0rr
parents:
diff changeset
    35
end.