Exception-Handling

Fabian

Member
Hello

I wanted to write an exception-handler in Delphi with DOA.

I implemented a central Exception-procedure:
Application.OnException := AppException;

What I wrote is:

with DataModule1.oscUserEdit do
try
Lines.Clear;
Lines.Add('ALTER USER "'+dbedLoginName.Text+'"');
Lines.Add('TEMPORARY TABLESPACE "'+dblcTts.text+'"');
Execute;
except
on E:EOracleError do ShowMessage(E.Message); //if the try failes it never passes this line
end;

Why does the exception-meassage already apear after the execute line failed?

What am I doing wrong? or is there a better Solution?

regards Fabian
 
Sorry, I notice now that it's a TOracleScript. This component does not raise EOracleError exceptions. Instead, you need to use the OnError event and the ExitOnError property to process errors. In the OnError event you can decide to display an error message, or to log it, and you can decide to cancel the script when an error is critical by setting the Finished property to True.
 
Hello Marco

Thank you for your answer. I have another question: How can I get the Error number in the OnError event?

Thank you.
 
Within the OnError event handler you can use the CurrentCommand property of the script to access the ErrorCode and ErrorMessage properties of the current command.
 
Back
Top