Have a look at
It tries to execute skill_expr,
if it is ok the result is return as list
if skill_expr rise an error then returns nil, if bool == t the error message is also printed.
errset(x = list(1 2 3))((1 2 3))errset(x = listx(1 2 3))nilerrset(x = listx(1 2 3) t)*Error* eval: undefined function - listxnil
The other approach I would recommend is actually checking the return values of various functions in your code. For example, v("/out" ?result 'tran) will return nil if that signal is not there. Similarly other functions may return nil (such as riseTime) if there is no rising edge - so conditional checks in your code will allow you to detect when things are not correct.
errset() is the alternative as Marcel suggested, but often more defensive programming will allow you to cope with differences in the data more eloquently than just trapping errors.
of course Andrew is right.
Better to use if/else to "validate" data.
I use errset when generate and execute skill code on the fly, sometimes I generate syntax errors or call missing/unexisting functions and that's the only way to catch them.
The logic is unassailable. But what can we do to make the programming easier. At our location we've had people take full-fledged ocean-scripting classes and still, no one uses it. It's extremely unfriendly. How can we go from "linux" to "ipad"?
Putting in all this error-checking will only make the code even more intimidating..
BTW, did you mean "elegantly" or "eloquently"? :)