Skip to content

Commit 8c1ed5d

Browse files
author
saville
committed
Handle container errors correctly
1 parent c1aa57f commit 8c1ed5d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

buildrunner/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919
import tarfile
2020
import tempfile
21+
import traceback
2122
import types
2223
from typing import List, Optional
2324

@@ -35,6 +36,7 @@
3536
from buildrunner.errors import (
3637
BuildRunnerConfigurationError,
3738
BuildRunnerProcessingError,
39+
BuildRunnerError,
3840
)
3941
from buildrunner.steprunner import BuildStepRunner
4042
from buildrunner.docker.multiplatform_image_builder import MultiplatformImageBuilder
@@ -470,13 +472,6 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many
470472
)
471473
else:
472474
self.log.write("\nPush not requested\n")
473-
474-
except BuildRunnerConfigurationError as brce:
475-
exit_explanation = str(brce)
476-
self.exit_code = os.EX_CONFIG
477-
except BuildRunnerProcessingError as brpe:
478-
exit_explanation = str(brpe)
479-
self.exit_code = 1
480475
except requests.exceptions.ConnectionError as rce:
481476
print(str(rce))
482477
exit_explanation = (
@@ -486,6 +481,14 @@ def run(self): # pylint: disable=too-many-statements,too-many-branches,too-many
486481
"remote PyPi server information is set correctly."
487482
)
488483
self.exit_code = 1
484+
except BuildRunnerError as exc:
485+
exit_explanation = str(exc)
486+
self.exit_code = (
487+
os.EX_CONFIG if isinstance(exc, BuildRunnerConfigurationError) else 1
488+
)
489+
except Exception as exc:
490+
exit_explanation = f"Encountered unhandled exception ({type(exc).__name__}) {traceback.format_exc()}"
491+
self.exit_code = 1
489492

490493
finally:
491494
self._write_artifact_manifest()

0 commit comments

Comments
 (0)