Using SQLCODE and SQLERRM:
In an exception handler, the functions SQLERRM and SQLCODE can be used to search out that error has occurred and to get the related error message.
For internal exceptions, SQLCODE returns the number of the Oracle error. The number in which SQLCODE returns is negative unless the Oracle error is no data found, in that case SQLCODE returns +100. SQLERRM returns the corresponding error message. The message starts with the Oracle error code.
For user-defined exceptions, SQLCODE returns +1 and SQLERRM returns the message