Hi,
I have been using the script component as a work around for the inability of the query component to execute multiple commands and for the most part it works ok, except when a error occurs.
In most of my situations I have my own exception handler, for example
try
myscript.sql.add('some sql');
myscript.sql.add('some sql');
myscript.sql.add('somesql');
excute; //does not allow script exceptions to bubble up
modalresult:=mrok;
except
on e:exception do
showmessage(e.message);
end;
Because the script handles the errors it always executes the modalresult line, I tried using the scripts on error handler but it does not work the way I need it to.
The error handler would be ok if it had a option to abort and re raise the exception so the outside error handler picks up the exception.
I tried to re raise the exception that is passed in the even and then do a
eaAbort, but that does not work because the passed exeption goes out of scope and I get a invalid pointer error.
Please advise,
Snorkel
Small issue with pgscript component
Use the following handler for the OnError event:
In this case the script raises the exception, and you can catch it.
Code: Select all
procedure TForm1.PgScript1Error(Sender: TObject; E: Exception;
SQL: String; var Action: TErrorAction);
begin
Action := eaFail;
end;
hmm, I tried that in the build I have and it didn't seem to re raise the exception so it was caught in the external try except.Plash wrote:Use the following handler for the OnError event:In this case the script raises the exception, and you can catch it.Code: Select all
procedure TForm1.PgScript1Error(Sender: TObject; E: Exception; SQL: String; var Action: TErrorAction); begin Action := eaFail; end;