Ok, thank you ! So the way to go is "better ask for permission than for forgiveness" !
John Myles White a écrit :
I don't believe this is possible in Julia right now. Which is ok in this case, since working with a KeyError is a very un-Julian way to check for key existence. You'll want to use haskey instead. -- John On Nov 17, 2014, at 2:49 PM, Luthaf<[email protected]> wrote:Hello ! Is there a way to catch an exception by type in Julia ? Coming from python, I am very tempted to do this kind of things: ``` try # Access a dict here catch e if isa(KeyError, e) # Handle the KeyError, as I know what to do in that case else # Re-throw to upper level throw(e) end ``` But that is a lot of boilerplate when used many times. Maybe it is not the Julia way to express this kind of problem (handling one type of exception, while letting the others go up), but I could not find something about it. I can not just remove all the exceptions as some of them are thrown by Base. Thank for yours answers ! Guillaume
