boen_robot came up with this trick:
:local scripts [/system script print detail as-value]
#Create pseudo files (RouterOS can't create empty ones at will)
:foreach script in=$scripts do={
/file print file=(($script->"name") . ".rsc")
}
#Wait for the files to be created "for real"
:delay 2s
#Fill the files with the script's contents
:foreach script in=$scripts do={
/file set (($script->"name") . ".rsc") contents=($script->"source")
}
It failed with failure: new contents too long.
Now it is possible to sort of try...catch A.K.A. try...except using on-error=, but how to get back the error message is not in the on-error= documentation (the best documentation is actually the Catch run-time errors example as on-error= is not part of the :execute command, but part of the :do command).
Is there a way to get the error message?
When not: Why is that missing and where to put in a feature request?
–jeroen