delphi obtains program exception information

Updated on technology 2024-03-20
2 answers
  1. Anonymous users2024-02-07

    Supplements

    If you want to get the whole program error, then you need to write exception handling in the project file

    program project1;

    usesforms, sysutils,unit1 in '' ;

    r *.res}

    begintry

    = true;

    form1);

    except

    on e: exception do

    error', 16);

    end;end;end.

    Yes, the exception handling in Delphi is very good, and here's an example:

    procedure : tobject);

    var ii:integer;

    beginusedtime:=0;

    true;Try the following process for your own. A judgment on the usedtime is added in the middle. If it's longer than your scheduled time, an exception is thrown.

    for ii:=1 to 100000000 do

    if usedtime>=2 then

    raise 'your custom error message! for example : timeout!');Throws a custom exception.

    end;except

    Here you can use on e: exception do begin....end;to capture error messages.

    showmessage('timeout!');

    false;

    end;end;

    procedure : tobject);

    beginusedtime:=usedtime+1;

    end;end.

    The key here is to throw an exception with raise after the time conditions you set are met! This allows the program to go directly into the except statement.

  2. Anonymous users2024-02-06

    1. Compound sentences (or sentence structure, sentence framework, sentence pattern, etc.) 1. Extensive.

    tryfinallyend and.

    tryexcept

    end2, fine.

    tryexcept

    on Exception 1:

    What to do when exception 1 occurs.

    on Exception 2:

    What to do when Exception 2 occurs.

    on Exception n:

    What to do when an exception N occurs.

    end2. Simple statement.

    Raise actively throws an exception for processing by the outer exception handling mechanism; If the program does not have its own processing mechanism, it will be handled by the operating system, or the outermost processing mechanism is the operating system, and the processing method is generally a pop-up dialog box.

    3. Examples of nesting methods. try

    tryexcept

    onex1:

    doex1;

    onex2:

    doex2;

    onexn:

    raise;

    Do not dispose of it yourself, dispose of it by the outer layer.

    endfinallyend

Related questions
14 answers2024-03-20

function getsqlserverlist(strings:tstrings):boolean;

The function is implemented as follows: >>>More

6 answers2024-03-20

1. Observation method: through meetings, in-depth on-site, participation in production and operation, on-site sampling, on-site observation and accurate recording (including surveying and mapping, audio and video, photography, transcripts, etc.) of the investigation. >>>More

3 answers2024-03-20

Hello! There are generally three possible application exceptions: >>>More

3 answers2024-03-20

Lonely 1217 Practical experience with application errors:

Start-->Run--> enter cmd and enter in the command prompt (paste the following characters). >>>More

8 answers2024-03-20

Your anomaly was triggered, but it was eaten.

Because the using statement is actually try....Finally, your ** is equivalent to. >>>More