Skip to content

Commit d1a0480

Browse files
committed
Update external command error message.
This message could now display for several different external commands besides editor.
1 parent 841ac71 commit d1a0480

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

alot/commands/globals.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ async def apply(self, ui):
312312
if self.on_success is not None:
313313
self.on_success(out)
314314
else:
315-
msg = "editor has exited with error code {} -- {}".format(
315+
msg = (
316+
"external command has exited with error code {} -- {}".format(
316317
"None" if proc is None else proc.returncode,
317-
ret or "No stderr output")
318+
ret or "No stderr output"))
318319
ui.notify(msg, priority='error')
319320
if self.refocus and callerbuffer in ui.buffers:
320321
logging.info('refocussing')

tests/commands/test_global.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def test_get_template_decode(self):
105105

106106

107107
class TestExternalCommand(unittest.TestCase):
108+
NO_STDERR_MSG = (
109+
'external command has exited with error code 1 -- No stderr output'
110+
)
108111

109112
@utilities.async_test
110113
async def test_no_spawn_no_stdin_success(self):
@@ -126,9 +129,7 @@ async def test_no_spawn_no_stdin_attached(self):
126129
ui = utilities.make_ui()
127130
cmd = g_commands.ExternalCommand('test -p /dev/stdin', refocus=False)
128131
await cmd.apply(ui)
129-
ui.notify.assert_called_once_with(
130-
'editor has exited with error code 1 -- No stderr output',
131-
priority='error')
132+
ui.notify.assert_called_once_with(self.NO_STDERR_MSG, priority='error')
132133

133134
@utilities.async_test
134135
async def test_no_spawn_stdin_attached(self):
@@ -143,9 +144,7 @@ async def test_no_spawn_failure(self):
143144
ui = utilities.make_ui()
144145
cmd = g_commands.ExternalCommand('false', refocus=False)
145146
await cmd.apply(ui)
146-
ui.notify.assert_called_once_with(
147-
'editor has exited with error code 1 -- No stderr output',
148-
priority='error')
147+
ui.notify.assert_called_once_with(self.NO_STDERR_MSG, priority='error')
149148

150149
@utilities.async_test
151150
@mock.patch(
@@ -177,9 +176,7 @@ async def test_spawn_failure(self):
177176
ui = utilities.make_ui()
178177
cmd = g_commands.ExternalCommand('false', refocus=False, spawn=True)
179178
await cmd.apply(ui)
180-
ui.notify.assert_called_once_with(
181-
'editor has exited with error code 1 -- No stderr output',
182-
priority='error')
179+
ui.notify.assert_called_once_with(self.NO_STDERR_MSG, priority='error')
183180

184181

185182
class TestCallCommand(unittest.TestCase):

0 commit comments

Comments
 (0)