Sql error catching and processing

In my system there are some error that I create in triggers and would like to process them to give the user a message that he can understand.
What i is, I get the the message return by $e->getmessage() and check if it has a specific string(message I generate for error such unknow column THE_RECORD_MUST_NOT_BE_UPDATED) instead of showing the sql error then I show the message with javascript the record must not be updated.

So how can I catch and handle that in SCriptcase?

I got the answer while reading macro part in the manual so I can use in onafterdelete or onafterinsert or onAfterUpdate I can access {sc_erro_delete} and use sc_error_continue(“Event”) to read the message.