Quick exception handling

From Cuis CookBook
Revision as of 21:20, 4 May 2025 by Nmingott (talk | contribs) (imported material)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Problem. You have a code block that may fail but you don't want to open the Debugger when it fails, instead you want to run a plan-B in those cases.

Solution. In the following example the code block containing a division will fail for sure, when it fails we want to return nil and write a message into the Transcript.

[ 1/0 ] on: Error do: [
	Transcript log: 'Error, division failed, result set to nil. '. 
	nil ].