Skip to main content

Hello,

I have made an event that throws an error message to the user, using the error_sys.record_general function, based on some criteria set in the event, which triggers on a change in the status of the object. 

error_sys.record_general( 'SomeLogicUnit', 'SOMEERRORMSG: this is an error message');

I am in the process of creating another event that will change the status of the object, but I am wondering if it is possible to catch the exception raised in the other event, and handle it separately? 

Without handling the event, and running the event manually in a DBMS, the procedure completes, but returns

ORA-20110: SomeLogicUnit.SOMEERRORMSG: this is an error message

 

My event would look something like this:

BEGIN

--change status on object, which may cause an error to be raised in the other event

EXCEPTION
WHEN ... THEN
-- handle the exception raised from the other event
END;

If I specify “EXCEPTION WHEN others THEN … “ I will catch the error raised in the other event, but I won’t know the source of the error, or the error itself for that matter. Is there a way for me to handle that specific error, or would I have to declare and raise the error in the source event manually? 

Yes, you can catch a known exception, based on a number that you know. Have a read here (this is just one page that explains it, I am sure there are hundreds more):

https://docs.oracle.com/cd/B10501_01/appdev.920/a96624/07_errs.htm

Especially, have a look at this section:

Associating a PL/SQL Exception with a Number: Pragma EXCEPTION_INIT

Good luck!
 


Reply