The new MIAMEX function MX_BASERR (201) allows you to arbitrarily trigger a BASIC error:
xcall MIAMEX, MX_BASERR, eno
Parameters
eno (num) [in]
the BASIC error number to set.
The effect is immediate, as if the error had occurred naturally at the location of the XCALL.
This can be useful for handling errors within functions where you want to make sure that the caller doesn't overlook an error condition.
MX_BASERR is similar to XCALL ASFLAG, AF_SETCTRLC, except that the ASFLAG version only supports error #1, and is only works within an SBX call (detected on return).