forked from Mirror/pmbootstrap
pmb: Handle BuildFailedError (MR 2288)
Also breaks out hinting printing code into its own function to avoid repetition. Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2068
This commit is contained in:
parent
d5badd1b0e
commit
2972f1d36e
1 changed files with 18 additions and 9 deletions
|
@ -5,8 +5,9 @@ import sys
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
from argparse import Namespace
|
||||||
|
|
||||||
from pmb.helpers.exceptions import NonBugError
|
from pmb.helpers.exceptions import BuildFailedError, NonBugError
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
from . import parse
|
from . import parse
|
||||||
|
@ -28,6 +29,16 @@ if version < (3, 9):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def print_log_hint(args: Namespace) -> None:
|
||||||
|
# Hints about the log file (print to stdout only)
|
||||||
|
log_hint = "Run 'pmbootstrap log' for details."
|
||||||
|
if not args or not os.path.exists(args.log):
|
||||||
|
log_hint += (" Alternatively you can use '--details-to-stdout' to get more"
|
||||||
|
" output, e.g. 'pmbootstrap --details-to-stdout init'.")
|
||||||
|
print()
|
||||||
|
print(log_hint)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Wrap everything to display nice error messages
|
# Wrap everything to display nice error messages
|
||||||
args = None
|
args = None
|
||||||
|
@ -80,6 +91,11 @@ def main():
|
||||||
logging.error(exception)
|
logging.error(exception)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
except BuildFailedError as exception:
|
||||||
|
logging.error(exception)
|
||||||
|
print_log_hint(args)
|
||||||
|
return 3
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Dump log to stdout when args (and therefore logging) init failed
|
# Dump log to stdout when args (and therefore logging) init failed
|
||||||
if not args:
|
if not args:
|
||||||
|
@ -89,14 +105,7 @@ def main():
|
||||||
logging.info("See also: <https://postmarketos.org/troubleshooting>")
|
logging.info("See also: <https://postmarketos.org/troubleshooting>")
|
||||||
logging.debug(traceback.format_exc())
|
logging.debug(traceback.format_exc())
|
||||||
|
|
||||||
# Hints about the log file (print to stdout only)
|
print_log_hint(args)
|
||||||
log_hint = "Run 'pmbootstrap log' for details."
|
|
||||||
if not args or not os.path.exists(args.log):
|
|
||||||
log_hint += (" Alternatively you can use '--details-to-stdout' to"
|
|
||||||
" get more output, e.g. 'pmbootstrap"
|
|
||||||
" --details-to-stdout init'.")
|
|
||||||
print()
|
|
||||||
print(log_hint)
|
|
||||||
print()
|
print()
|
||||||
print("Before you report this error, ensure that pmbootstrap is "
|
print("Before you report this error, ensure that pmbootstrap is "
|
||||||
"up to date.")
|
"up to date.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue