halt() generates a HaltException

75 views
Skip to first unread message

Warren Strange

unread,
Oct 20, 2011, 6:14:57 PM10/20/11
to scalat...@googlegroups.com

Which I now know  is completely obvious but I would suggest the book mention this :-)

As a newbie I had a halt within a try/catch block and couldn't figure out why the halt never took effect.... 



Ross A. Baker

unread,
Oct 21, 2011, 12:56:59 AM10/21/11
to scalat...@googlegroups.com

That's an implementation detail that we hope to to hide from
applications, but it leaks out in that particular case. Likewise with
pass and redirect. I will add these to the book, thanks.

--
Ross A. Baker
ba...@alumni.indiana.edu
Indianapolis, IN, USA

Ruslan Shevchenko

unread,
Oct 21, 2011, 1:47:46 AM10/21/11
to scalat...@googlegroups.com
Btw, it is possible to inherit messenger-s from Throwable, not from Exception
which will reduce such side effects. [Usually user code does not
catch Throwables,
only Exceptions]. So, this can be suggestion for small refactoring in
next version.

Ross A. Baker

unread,
Oct 21, 2011, 4:56:27 PM10/21/11
to scalat...@googlegroups.com
Good idea. The proper parent is scala.util.control.ControlThrowable,
which I just checked in. Thanks to Stefan on IRC for the link:

http://www.tzavellas.com/techblog/2010/09/20/catching-throwable-in-scala/

Key point for application developers: { catch e => ... } is usually
wrong. { catch e: Exception => ... } is about as general as you want
to go unless you have a good reason.

Reply all
Reply to author
Forward
0 new messages