Report unahndled exceptions when starting loop in URL hints kitten
This commit is contained in:
parent
bc829a9712
commit
dd128a99ac
@ -171,6 +171,20 @@ def mark(finditer, line, index_map):
|
|||||||
return line, marks
|
return line, marks
|
||||||
|
|
||||||
|
|
||||||
|
def run_loop(args, lines, index_map):
|
||||||
|
loop = Loop()
|
||||||
|
handler = URLHints(lines, index_map)
|
||||||
|
loop.loop(handler)
|
||||||
|
if handler.chosen and loop.return_code == 0:
|
||||||
|
cmd = command_for_open(args.program)
|
||||||
|
ret = subprocess.Popen(cmd + [handler.chosen]).wait()
|
||||||
|
if ret != 0:
|
||||||
|
print('URL handler "{}" failed with return code: {}'.format(' '.join(cmd), ret), file=sys.stderr)
|
||||||
|
input('Press Enter to quit')
|
||||||
|
loop.return_code = ret
|
||||||
|
raise SystemExit(loop.return_code)
|
||||||
|
|
||||||
|
|
||||||
def run(args, source_file=None):
|
def run(args, source_file=None):
|
||||||
if source_file is None:
|
if source_file is None:
|
||||||
text = sys.stdin.buffer.read().decode('utf-8')
|
text = sys.stdin.buffer.read().decode('utf-8')
|
||||||
@ -195,17 +209,12 @@ def run(args, source_file=None):
|
|||||||
input(_('No URLs found, press Enter to abort.'))
|
input(_('No URLs found, press Enter to abort.'))
|
||||||
return
|
return
|
||||||
|
|
||||||
loop = Loop()
|
try:
|
||||||
handler = URLHints(lines, index_map)
|
run_loop(args, lines, index_map)
|
||||||
loop.loop(handler)
|
except Exception:
|
||||||
if handler.chosen and loop.return_code == 0:
|
import traceback
|
||||||
cmd = command_for_open(args.program)
|
traceback.print_exc()
|
||||||
ret = subprocess.Popen(cmd + [handler.chosen]).wait()
|
input(_('Press Enter to quit'))
|
||||||
if ret != 0:
|
|
||||||
print('URL handler "{}" failed with return code: {}'.format(' '.join(cmd), ret), file=sys.stderr)
|
|
||||||
input('Press Enter to quit')
|
|
||||||
loop.return_code = ret
|
|
||||||
raise SystemExit(loop.return_code)
|
|
||||||
|
|
||||||
|
|
||||||
OPTIONS = partial('''\
|
OPTIONS = partial('''\
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user