Handling ORA errors in APEX

One of the first things I noticed when making an APEX application, there was a lack of error handling. In particular, the error handling raised from an database procedure. For clarity, here a part of a screen as you will see after a unique constraint violation, the ORA-0001 error. I think the most horrible part is that this error is displayed on a new page!
I solved this problem for my situation, perhaps it can help you too.