summaryrefslogtreecommitdiff
path: root/alembic/script/write_hooks.py
diff options
context:
space:
mode:
Diffstat (limited to 'alembic/script/write_hooks.py')
-rw-r--r--alembic/script/write_hooks.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/alembic/script/write_hooks.py b/alembic/script/write_hooks.py
index 7d0843b..d6d1d38 100644
--- a/alembic/script/write_hooks.py
+++ b/alembic/script/write_hooks.py
@@ -39,9 +39,10 @@ def _invoke(name, revision, options):
"""
try:
hook = _registry[name]
- except KeyError:
- compat.raise_from_cause(
- util.CommandError("No formatter with name '%s' registered" % name)
+ except KeyError as ke:
+ compat.raise_(
+ util.CommandError("No formatter with name '%s' registered" % name),
+ from_=ke,
)
else:
return hook(revision, options)
@@ -65,12 +66,13 @@ def _run_hooks(path, hook_config):
opts["_hook_name"] = name
try:
type_ = opts["type"]
- except KeyError:
- compat.raise_from_cause(
+ except KeyError as ke:
+ compat.raise_(
util.CommandError(
"Key %s.type is required for post write hook %r"
% (name, name)
- )
+ ),
+ from_=ke,
)
else:
util.status(
@@ -89,12 +91,13 @@ def console_scripts(path, options):
try:
entrypoint_name = options["entrypoint"]
- except KeyError:
- compat.raise_from_cause(
+ except KeyError as ke:
+ compat.raise_(
util.CommandError(
"Key %s.entrypoint is required for post write hook %r"
% (options["_hook_name"], options["_hook_name"])
- )
+ ),
+ from_=ke,
)
iter_ = pkg_resources.iter_entry_points("console_scripts", entrypoint_name)
impl = next(iter_)