Add error handling for pipe command