Skip to content

Commit d12a4a8

Browse files
committed
bugs: improve error output
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent ad6cdeb commit d12a4a8

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,10 @@ def _find_dependencies(self, pkg: package, keywords: set[str]):
406406
match = self.find_best_match(deps, pkgset)
407407
except (ValueError, IndexError):
408408
deps_str = " , ".join(map(str, deps))
409-
self.err.error(
409+
bugs.error(
410410
f"unable to find match for restrictions: {deps_str}",
411+
status=3,
411412
)
412-
raise
413413
results[match].add(keyword)
414414
yield from results.items()
415415

@@ -427,8 +427,8 @@ def load_targets(self, targets: list[tuple[str, str]]):
427427
else: # no stablereq
428428
continue
429429
result.append(self.find_best_match([target], pkgset, False))
430-
except ValueError:
431-
raise ValueError(f"Restriction {target} has no match in repository")
430+
except (ValueError, IndexError):
431+
bugs.error(f"Restriction {target} has no match in repository", status=3)
432432
self.targets = tuple(result)
433433

434434
def build_full_graph(self):
@@ -617,7 +617,7 @@ def observe(node: GraphNode):
617617
node.file_bug(api_key, auto_cc_arches, block_bugs, modified_repo, observe)
618618

619619

620-
def _load_from_stdin(out: Formatter, err: Formatter):
620+
def _load_from_stdin(out: Formatter):
621621
if not sys.stdin.isatty():
622622
out.warn("No packages were specified, reading from stdin...")
623623
for line in sys.stdin.readlines():
@@ -626,7 +626,7 @@ def _load_from_stdin(out: Formatter, err: Formatter):
626626
# reassign stdin to allow interactivity (currently only works for unix)
627627
sys.stdin = open("/dev/tty")
628628
else:
629-
raise arghparse.ArgumentError(None, "reading from stdin is only valid when piping data in")
629+
bugs.error("reading from stdin is only valid when piping data in")
630630

631631

632632
@bugs.bind_main_func
@@ -637,7 +637,7 @@ def main(options, out: Formatter, err: Formatter):
637637
options.targets.extend(d.extend_maintainers())
638638
options.targets.extend(d.extend_targets_stable_groups(options.sets or ()))
639639
if not options.targets:
640-
options.targets = list(_load_from_stdin(out, err))
640+
options.targets = list(_load_from_stdin(out))
641641
d.load_targets(options.targets)
642642
d.build_full_graph()
643643
d.merge_stabilization_groups()

0 commit comments

Comments
 (0)