[Newbies] Exceptions in Squeak

Waldemar Schwan waldemar.schwan at googlemail.com
Wed Sep 3 00:26:01 UTC 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> What I wanted was an exception (try/except) in case any of the reads
> failed. Corrupt files are an expected case that should be handled by
> the program. So I can't crash while reading (or writing). Does Squeak
> have exceptions? Or is there a Smalltalk pattern for this "try to
> execute this, do something else if it fails"? That answer should
> probably go into another thread.
>
> David

You may take a look at BlockContext, exception protocoll. BlockContext  
is the class of [ ] .

If you are searching for a try catch, try
	[ self doingThingsThatMayThrowErrors ] on: Error do: [ something ].

example:
	[ Error new signal] on: Error do: [Transcript show: 'error'].


Regards
	Waldemar
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAki92ZkACgkQr7Iyerpx99kAXwCdHJNnjyMUr7UjK4HSvJdc4F8P
3TEAniVFQcpH6IdXfF1QDeyBDieEquFq
=U60m
-----END PGP SIGNATURE-----


More information about the Beginners mailing list