Skip to content

Commit eac6919

Browse files
committed
🐛 Catch TypeError from from_plugin_classname
This fixes issue #269. Previously we showed an unhelpful stack trace.
1 parent ff6c4a5 commit eac6919

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

detect_secrets/plugins/common/initialize.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ def from_plugin_classname(
165165
try:
166166
klass = import_plugins()[plugin_classname]
167167
except KeyError:
168-
log.warning('No such plugin to initialize.')
168+
log.error('Error: No such `{}` plugin to initialize.'.format(plugin_classname))
169+
log.error('Chances are you should run `pre-commit autoupdate`.')
170+
log.error(
171+
'This error occurs when using a baseline that was made by '
172+
'a newer detect-secrets version than the one running.',
173+
)
169174
raise TypeError
170175

171176
try:

detect_secrets/pre_commit_hook.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main(argv=None):
3232
# If baseline is provided, we first want to make sure
3333
# it's valid, before doing any further computation.
3434
baseline_collection = get_baseline(args.baseline[0])
35-
except (IOError, ValueError):
35+
except (IOError, TypeError, ValueError):
3636
# Error logs handled within logic.
3737
return 1
3838

0 commit comments

Comments
 (0)