Add error handler

This transform an connection error to an exception instead of aborting the program.