Changed the way in which unhandled exceptions are managed

Show client as offline, continue the main loop (do not terminate the
application) and properly log the exception