Skip to content

Commit

Permalink
Improve error reporting and fail on errors by default
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Sep 16, 2024
1 parent f602024 commit f1a8c86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ogc/bblocks/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

parser.add_argument(
'--fail-on-error',
default='false',
default='true',
help='Fail run if an error is encountered',
)

Expand Down
6 changes: 6 additions & 0 deletions ogc/bblocks/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import traceback
from urllib.parse import urljoin

from ogc.na.exceptions import ContextLoadError
from ogc.na.util import is_url, dump_yaml

from ogc.bblocks.generate_docs import DocGenerator
Expand Down Expand Up @@ -280,6 +281,11 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
if fail_on_error:
raise
traceback.print_exception(e, file=sys.stderr)
if isinstance(e, ContextLoadError):
if e.__cause__:
print(f"{e}: {e.__cause__}", file=sys.stderr)
else:
print(str(e), file=sys.stderr)

if building_block.openapi.exists:
print(f"Annotating OpenAPI document for {building_block.identifier}", file=sys.stderr)
Expand Down

0 comments on commit f1a8c86

Please sign in to comment.