Improve error reporting.

This commit is contained in:
Darko Poljak 2018-04-17 11:15:28 +02:00
commit f09765a03a
5 changed files with 68 additions and 29 deletions

View file

@ -259,10 +259,8 @@ class Local(object):
util.log_std_fd(self.log, command, stderr, 'Local stderr')
util.log_std_fd(self.log, command, stdout, 'Local stdout')
return output
except subprocess.CalledProcessError as e:
util.handle_called_process_error(e, command)
except OSError as error:
raise cdist.Error(" ".join(command) + ": " + error.args[1])
except (OSError, subprocess.CalledProcessError) as error:
raise cdist.Error(" ".join(command) + ": " + str(error.args[1]))
finally:
if message_prefix:
message.merge_messages()

View file

@ -343,10 +343,8 @@ class Remote(object):
util.log_std_fd(self.log, command, stdout, 'Remote stdout')
return output
except subprocess.CalledProcessError as e:
util.handle_called_process_error(e, command)
except OSError as error:
raise cdist.Error(" ".join(command) + ": " + error.args[1])
except (OSError, subprocess.CalledProcessError) as error:
raise cdist.Error(" ".join(command) + ": " + str(error.args[1]))
except UnicodeDecodeError:
raise DecodeError(command)
finally:

View file

@ -127,6 +127,7 @@ def call_get_output(command, env=None, stderr=None):
return (_call_get_stdout(command, env, stderr), None)
# Currently not used.
def handle_called_process_error(err, command):
# Currently, stderr is not captured.
# errout = None