The attached image shows what goes wrong.
In CodePad I enter:
but the TicketMachine constructor (shown) throws an exception when its ticketPrice argument is negative.
Unfortunately, the error that the CodePad prints is uninformative, probably because the expression is syntactically correct and only fails at runtime.
It might be better to catch the thrown exception and call that its value.
The error message could be:
Error: IllegalArgumentException thrown
and a little IllegalArgumentException mini-icon, draggable to the Object Bench in the usual way, could show up to the left.