I was trying to actually do a cast and trap the error but (beside nothaving succeeded in doing so) this is a much nicer way.
Thanks.Balázs