Question

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;
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top