1
votes

The following code snippet dosen't work as I expected, which I think will show the message I wanted it to show without the debugger exception notification 'Process raised exception class EAccessViolation with message 'Access violation at address 0045D9E7 in module XXXX'', but the programme runs opposite as I thougt.Why is that?

procedure TForm1.btn1Click(Sender: TObject);
begin
    try
    (WebBrowser1.Document as IHTMLDOCUMENT2).execCommand('Refresh',false,0);
    except
      ShowMessage('caught!');
    end;
end;
1
Why should the code raise an exception? WebBrowser1 unassigned? Document unassigned? External exception? Something else? - Sertac Akyuz
Not sure what you are asking -- how does it behave? What do you expect it to do? Are you aware that by default the debugger will always show exceptions? - Nick Hodges
@SertacAkyuz WebBrowser1 should navigate to some website first before it refreshes. - world peace
@world - Sure. It could have done that f.i. in form create.. - Sertac Akyuz
@NickHodges I expect it to do some error handling which in this case is to show a message instead of showing the debugger's notification. - world peace

1 Answers

4
votes

Unless "Notify on Language Exceptions" in "Language Exceptions" of debugger options is unchecked, or "EAccessViolation" is one of the exception types to ignore in the same dialog, the debugger halts the program and shows the exception as soon as a language exception is raised.

Note that according to the documentation, if the "Notify on Language Exceptions" checkbox is checked, the debugger ignores the list in the "exception types to ignore". However, this is does not seem to be the case with every Delphi verison. With my tests, D2007 conforms with the ignore list (even when the box is unchecked). With XE2, I can't make it to ignore an EAccessViolation in any way.