The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Smalltalk Daily 12/22/09: Using Exception Handlers

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Smalltalk Daily 12/22/09: Using Exception Handlers Posted: Dec 22, 2009 8:31 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Smalltalk Daily 12/22/09: Using Exception Handlers
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

Today's Smalltalk Daily looks at using Exception Handlers in Smalltalk.

The Examples used in the screencast:


"simple exception handling"
answer := [4/0]
		on: ZeroDivide
		do: [:ex | ex returnWith: 0].

"a simple exception"
aString := 'This is a String'.
aString at: 3 put: $f.

"now do a retry"
[aString at: 3 put: $f]
	on: NoModificationError
	do: [:ex | aString beMutable.
		ex retry].
^aString

"Handle more than one"
content := [HttpClient new get: 'http://www.cincomsmalltalk.com']
		on: HttpException, OSErrorHolder peerFaultSignal, OSErrorHolder transferFaultSignal, OSErrorHolder operationStartedSignal
		do: [:ex | ex returnWith: nil].

"create the set of exceptions"
toHandle := ExceptionSet new.
toHandle 
	add: HttpException;
	add: OSErrorHolder peerFaultSignal;
	add: OSErrorHolder transferFaultSignal;
	add: OSErrorHolder operationStartedSignal.
^toHandle

To watch, click on the viewer below:

If you have trouble viewing that directly, you can click here to download the video directly

You can also watch it on YouTube:

Technorati Tags: , ,

Read: Smalltalk Daily 12/22/09: Using Exception Handlers

Topic: Firefox for the Win? Previous Topic   Next Topic Topic: Self Inflicted Agile Injuries

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use