Generates a mishap, causing the script to stop. The error message that
is reported will be constructed from the mishap functions
arguments.
Each line in a mishap report is made up of two parts, a label and a message. The label and message are separated by a colon. Consider the following simple example:
:-) mishap();
MISHAP : null
DOING : <function mishap>
LINE NO. : 1
PHASE : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
In the above example, the labels are MISHAP, DOING,
LINE NO., PHASE and Trapped, while the
messages are null, <function mishap>,
1, Evaluation, etc.
The labels and messages for your mishap are specified by the arguments
you supply to the mishap function. There is no limit to the
number of arguments you can supply, but their types must be selected
from the following list:
:-) mishap( "I've got a sore head", "Drank too much" );
MISHAP : I've got a sore head
BECAUSE : Drank too much
DOING : <function mishap>
LINE NO. : 1
PHASE : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
:-) mishap( newList( "label", "message", "label2", "message" ) );
MISHAP : null
LABEL : message
LABEL2 : message
DOING : <function mishap>
LINE NO. : 1
PHASE : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
:-) mishap( newMap( "label" ==> "message", "label2" ==> "message" ) );
MISHAP : null
LABEL : message
LABEL2 : message
DOING : <function mishap>
LINE NO. : 1
PHASE : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
:-) mishap( "label" ==> "message", "label2" ==> "message" );
MISHAP : null
LABEL : message
LABEL2 : message
DOING : <function mishap>
LINE NO. : 1
PHASE : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
So to bring everything together, we could use the mishap
function as follows:
:-) mishap(
:-) "I've got a sore head",
:-) "pints" ==> 5,
:-) "Drank too much",
:-) newList( "shots", 7 ),
:-) newMap( "kebab" ==> false )
:-) );
MISHAP : I've got a sore head
BECAUSE : Drank too much
KEBAB : false
PINTS : 5
SHOTS : 7
DOING : <function mishap>
LINE NO. : 1
PHASE : Evaluation
Trapped : org.millscript.millscript.Alert$EscapeException
Resetting input and resuming execution
There are two label-message pairs that need special attention, the COMPLAINT and REASON, which are displayed as MISHAP and BECAUSE respectively. e.g.
:-) mishap( "a complaint", "a reason" );
MISHAP : I've got a sore head
BECAUSE : Drank too much
...
Resetting input and resuming execution
:-) mishap( "complaint" ==> "a complaint", "reason" ==> "a reason" );
MISHAP : I've got a sore head
BECAUSE : Drank too much
...