Hi, you can use BlockClosure>>on:do:, like this:

[ #() atRandom ] on: Exception do: [ 1 ].

Personally, I would check the collection to be empty before calling.

On Nov 26, 2015, at 1:33 PM, abdelghani ALIDRA <alidrandco@yahoo.fr> wrote:

Hi everyBody,

I know there is some kind of exceptions handling mechanism  in Pharo but I cant exactly  remember where to find it.
Actually, I would like to execute specific code if atRandomis called on an empty Array or Collection.
I probably can still override errorEmptyCollection but maybe there is another (less radical) way.
And by the way, Would it be quicker to use exception handling then just testing the Collection before calling atRandom.

Thanks

Abdelghani