diff options
Diffstat (limited to 'support')
-rw-r--r-- | support/lib/util.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/support/lib/util.py b/support/lib/util.py index 3a852f4..915e33c 100644 --- a/support/lib/util.py +++ b/support/lib/util.py @@ -2,7 +2,8 @@ import contextlib, subprocess, tempfile, shutil, re, os class UserError(Exception): - pass + def __init__(self, message, *args): + super(UserError, self).__init__(message.format(*args)) def rename_atomic(source_path, target_path): @@ -43,11 +44,14 @@ def command(args, remove_env = [], set_env = { }): for k, v in set_env.items(): env[k] = v - process = subprocess.Popen(args, env = env) - process.wait() + try: + process = subprocess.Popen(args, env = env) + process.wait() + except OSError as e: + raise UserError('Error running {}: {}', args[0], e) if process.returncode: - raise UserError('Command failed: {}'.format(' '.join(args))) + raise UserError('Command failed: {}', ' '.join(args)) def bash_escape_string(string): |