Fix exception handling when loading packages (#5569)

This commit is contained in:
dentra 2023-10-25 21:15:25 +03:00 committed by GitHub
parent e80bd8ed3d
commit ec835c0b05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,17 +139,22 @@ def _process_base_package(config: dict) -> dict:
) from e ) from e
return packages return packages
packages = {} packages = None
error = ""
try: try:
packages = get_packages(files) packages = get_packages(files)
except cv.Invalid: except cv.Invalid as e:
if revert is not None: error = e
revert() try:
packages = get_packages(files) if revert is not None:
finally: revert()
if packages is None: packages = get_packages(files)
raise cv.Invalid("Failed to load packages") except cv.Invalid as er:
error = er
if packages is None:
raise cv.Invalid(f"Failed to load packages. {error}")
return {"packages": packages} return {"packages": packages}