Skip to content

Commit 0cd6e62

Browse files
committed
core: handle FileNotFound error when launching commands
Gracefuly handle errors when attempting to launch a command that does not exist by catching the exception and returning the expected status code and program output. The exception text is returned as "stderr". This prevents errors when aspell is enabled on systems that do not have the `aspell` binary installed. Signed-off-by: David Aguilar <davvid@gmail.com>
1 parent a404842 commit 0cd6e62

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cola/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ def run_command(cmd, *args, **kwargs):
273273
274274
"""
275275
encoding = kwargs.pop('encoding', None)
276-
process = start_command(cmd, *args, **kwargs)
276+
try:
277+
process = start_command(cmd, *args, **kwargs)
278+
except FileNotFoundError as err:
279+
return (EXIT_UNAVAILABLE, UStr('', ENCODING), UStr(f'{err}', ENCODING))
277280
(output, errors) = communicate(process)
278281
output = decode(output, encoding=encoding)
279282
errors = decode(errors, encoding=encoding)

0 commit comments

Comments
 (0)