handle exceptions in ApiCommand
Add some logging and error handling