Grid Application php button I need stop application for see error

I can’t get that the apllication when doesn’t give any error execute sc_exit(sel) and on other case I want to show the ok button for the user can read th error message.
Always execute sc_exit(ok) although there isn’t any error.
Is there any way to do that.?
thanks

try {
_sql_execPost($sql,true);
sc_exit(sel);
}
catch (Exception $e)
{
sc_error_message(($e->getMessage()));
sc_error_exit();
{sc_exit(ok);}

}

is that a valid function?

Yes, it’s customed function of mine. It’s work well