Error Handling Functions
assert(val, ruleName)
Tests the rule with the specified name. If it evaluates to true, val is returned. If the rule evaluates to false, a costing exception is thrown (halting costing at that level). If a message is associated with the rule that failed, that message is used in the costing exception.
assert(val, ruleName, message)
Tests the rule with the specified name. If it evaluates to true, val is returned. If the rule evaluates to false, a costing exception using message is thrown (halting costing at that level).
fail(message)
Throws a costing exception using message (halting costing at that level).  
msg(x, y, ...)
Takes one or more arguments and returns a string that is the concatenation of the string form of each argument. Decimal precision is limited to four digits after the decimal. This function can be nested inside fail() or assert() calls to improve messaging.
Examples:
 
message = fail('Literal')
message2 = fail(indirect)
 
indirect = 'Indirect'
 
//bar throws an exception with the message 'Zero val indirect'
bar = {
fail(zeroval) if (1 > 0)
3 otherwise
}
 
//message3 causes a failure whose message is "The diameter -1 is bogus."
message3 = fail(msg('The diameter: ', diameter, ' is bogus.'))
diameter = -1
 
//assert tests
atrue = assert(foo, myrule) //Returns 7
atruemsg = assert(foo, myrule, 'Should pass') //Returns 7
atruemsgindirect = assert(foo, myrule, shouldpass) //Returns 7
foo = 7
shouldpass = 'Should pass indirect'
Rule myrule: 1 > 0
 
afalse = assert(foo, myfailrule) //Throws an exception with a default message
 
//Throws an exception with the message 'Zero val'
afalsemsg = assert(foo, myfailrule, 'Zero val')
 
//Throws an exception with the message 'Zero val indirect'
afalsemsgindirect = assert(foo, myfailrule, zeroval)
 
zeroval = 'Zero val indirect'
 
Rule myfailrule: 1 < 0
 
inline = 3 + assert(foo, myrule, shouldpass) //Returns 10
 
//Throws an exception with the message 'Zero val indirect'
inlinefail = 3 + assert(foo, myfailrule, zeroval)
 
// Compute Cycle Time for Each Bend
 
//operation cycletime in secs
cycleTime = machine.bendCycleTime + manipulationTimePerBend
 
cycleTime = fail('Test fail.')
 
finishMass = part.volume * material.density * 1e-9
 
//use finish part mass as we can assume that bending occurs after
//all material removed by other ops
partMass = finishMass
 
// time (secs) for load/unload etc within the process cycle (secs)
manipulationTimePerBend = _
select first(entry.manipulationAllowance) _
from smBendBrakeHandling entry _
where entry.weight >=partMass _
order by entry.manipulationAllowance