properly handle exceptions in commands

Exceptions being thrown in the client library don't cause the commands
to be terminated unexpectedly, but show a nice error message instead.