. .


ST 4U 198: Raising Exceptions in VA Smalltalk

February 24, 2012 7:47:17.524

Today's Smalltalk 4 You looks at raising exceptions in VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:


If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Today we'll take a look at raising exceptions (either your own or existing ones already defined) in VA Smalltalk. We'll use a somewhat artificial example to demonstrate:

var1 := 10.
var2 := '2'.
(var1 isString or: [var2 isString])
  ifTrue: [MessageNotUnderstood signal: 'Cannot Add Strings']
  ifFalse: [var1 + var2].

This code raises the MessageNotUnderstood exception when it sees that we are trying to add a string to a number. The larger point is that this is how you raise an exception in VA (or most other Smalltalks) - see class Exception for the full range of API options.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

[st4u198-iPhone.m4v ( Size: 3535827 )]

posted by James Robertson

 Share Tweet This