unfortunately there's no easy way to check for built-ins so you'd probably have to check against a hardcoded list of existing commands in your script.
It's possible to fetch mIRC's internal errors:
alias !msg {
msg # $iif($1,$1-)
return
:error
if (/msg: insufficient parameters isin $error) {
echo 4 -a * The error $qt($v1) has been caught!
reseterror
}
}
/msg <message> will send a message to the channel. Without the message but the /msg command, it'll echo that the error has been caught in red.