I use a combination of a modal window to provide an error message for the user, and throw to terminate execution.
Example Date Check = Function({start_date,end_date},
chk1 = Is String(start_date);
If (!chk1 == 0,
emsg = "Invalid start date [" || char(start_date) || "]";
ew = new window("Invalid date", << modal(),
text box(emsg),
);
throw(emsg);
);
chk2 = Is String(end_date);
If (!chk2 == 0,
emsg = "Invalid end date [" || char(end_date) || "]";
ew = new window("Invalid date", << modal(),
text box(emsg),
);
throw(emsg);
);
);
example date check(today(), today());
example date check("31-Feb-2018", today());