carefully2.1

carefully [ commands1 ] [ commands2 ]

Runs commands1. If a runtime error occurs inside commands1, NetLogo won't stop and alert the user that an error occurred. It will suppress the error and run commands2 instead.

The error-message reporter can be used in commands2 to find out what error was suppressed in commands1. See error-message.

carefully [ print one-of [1 2 3] ] [ print error-message ]
=> 3
observer> carefully [ print one-of [] ] [ print error-message ]
=> ONE-OF got an empty list as input.

Take me to the full NetLogo Dictionary