mishap( ( string | list | map | maplet )... )

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:

string
String arguments do not have labels, so MillScript provides them for you. As a result, you can only have two plain string arguments, the first is given a label COMPLAINT and the second REASON.
:-) 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
          
list
Lists are assumed to contain a sequence of label-message pairs, hence they must contain a multiple of two items. e.g.
:-) 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
          
map
Maps contain key-value pairs, so each key-value pair is interpreted as a label-message for the mishap. e.g.
:-) 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
          
maplet
Maplets are pairs, so they are interpreted as a label-message pair. e.g.
:-) 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
      

Notes

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
...