All errors generated by Common SQL are of type sql-user-error or sql-database-error. You can test for these conditions and their subtypes in your error handlers.