comparison hglib/client.py @ 169:e6589149b2c8 1.9

client: include stderr message in ServerError on initial communication failure If _readhello() raises ServerError, the server must be unusable. So we can terminate it to get status code and error message.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 07 Sep 2015 22:45:47 +0900
parents d71bd813c9d7
children 2725547a5f92
comparison
equal deleted inserted replaced
168:d71bd813c9d7 169:e6589149b2c8
188 def open(self): 188 def open(self):
189 if self.server is not None: 189 if self.server is not None:
190 raise ValueError('server already open') 190 raise ValueError('server already open')
191 191
192 self.server = util.popen(self._args, self._env) 192 self.server = util.popen(self._args, self._env)
193 self._readhello() 193 try:
194 self._readhello()
195 except error.ServerError:
196 ret, serr = self._close()
197 raise error.ServerError('server exited with status %d: %s'
198 % (ret, serr.strip()))
194 return self 199 return self
195 200
196 def close(self): 201 def close(self):
197 """Closes the command server instance and waits for it to exit, 202 """Closes the command server instance and waits for it to exit,
198 returns the exit code. 203 returns the exit code.