Moving ouput method inside a try and catch clause