Handle exeptions in IO monad