Skip to content

Commit

Permalink
app: point "handle_unknown_command()" error message to "west -vv status"
Browse files Browse the repository at this point in the history
Commit d842371 ("app: handle unexpected command name better")
intentionally created a big error handling difference between extensions
and built-in commands. As an unfortunate side effect, it lost the
relevant "manifest import failure" error messages for _extension_
commands.  This is especially ironic when the extension command is
missing because the import failed, see example in #726.

Error handling is generally very hard to test comprehensively and even
more so in this complex "bootstrap" area. Rather than trying to refactor
it once again, tweak the existing error messages to gently steer the
user away from (potentially missing) extensions and towards built-in
commands that provide a simpler and better error handling out of the
box: they still show relevant, manifest error messages! Always have.

Also recommand the -vv option which conveniently includes git error
messages like "dubious ownership" since previous commit
23db6e1 ("app: re-work logging yet again") from the same giant PR

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and carlescufi committed Aug 27, 2024
1 parent d9c71b1 commit 45762a0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/west/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,11 @@ def handle_early_arg_errors(self, early_args):
self.handle_unknown_command(early_args.command_name)

def handle_unknown_command(self, command_name):
# "status" needs "-vv" to show git errors like "dubious ownership"; see #726
if self.topdir:
extra_help = (f'workspace {self.topdir} does not define '
'this extension command -- try "west help"')
'this extension command -- try "west help"'
' and "west -vv status"')
else:
extra_help = 'do you need to run this inside a workspace?'
self.print_usage_and_exit(f'west: unknown command "{command_name}"; '
Expand Down Expand Up @@ -1060,10 +1062,10 @@ def mie_msg(mie):
# what west.manifest needs to happen before we can
# resolve the missing import.
ret += (f' from revision "{p.revision}"\n'
f' Hint: {p.name} must be cloned and its '
f' Hint: {p.name} must be cloned, owned by the user and its '
f'{MANIFEST_REV_BRANCH} ref must point to a '
'commit with the import data\n'
' To fix, run "west update"')
' To fix, run "west update. If it still fails, try "west -vv ..."')

return ret

Expand Down

0 comments on commit 45762a0

Please sign in to comment.