Skip to content

Commit

Permalink
Use explicit re-raise chaining in util modules
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Sep 20, 2020
1 parent c7a3e2d commit 45a0e3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions octomachinery/github/utils/event_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def _probe_yaml(event_file_fd):
),
3,
)
except yaml.parser.ParserError:
raise ValueError('YAML file is not valid')
except yaml.parser.ParserError as yaml_err:
raise ValueError('YAML file is not valid') from yaml_err
finally:
event_file_fd.seek(0)

Expand Down Expand Up @@ -108,8 +108,8 @@ def validate_http_headers(headers):
x_gh_delivery_exc = ValueError('X-GitHub-Delivery must be of type UUID4')
try:
x_gh_delivery_uuid = UUID(headers['x-github-delivery'])
except ValueError:
raise x_gh_delivery_exc
except ValueError as val_err:
raise x_gh_delivery_exc from val_err
if x_gh_delivery_uuid.version != 4:
raise x_gh_delivery_exc

Expand Down
4 changes: 3 additions & 1 deletion octomachinery/runtime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __getattr__(self, name):
try:
return self.__map__[name].get()
except LookupError:
raise ContextLookupError(f'No `{name}` present in the context')
raise ContextLookupError(
f'No `{name}` present in the context',
) from None

def __setattr__(self, name, value):
if name in ('__map__', '__token_map__'):
Expand Down

0 comments on commit 45a0e3d

Please sign in to comment.