Adding error handling to client.rs