Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utilize GarakException in cli #730

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion garak/_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import List

from garak import _config
from garak.exception import GarakException

PLUGIN_TYPES = ("probes", "detectors", "generators", "harnesses", "buffs")
PLUGIN_CLASSES = ("Probe", "Detector", "Generator", "Harness", "Buff")
Expand Down Expand Up @@ -151,7 +152,7 @@ def load_plugin(path, break_on_fail=True, config_root=_config) -> object:
"error instantiating module %s class %s", str(mod), plugin_class_name
)
if break_on_fail:
raise Exception(e) from e
raise GarakException(e) from e
else:
return False

Expand Down
8 changes: 5 additions & 3 deletions garak/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def main(arguments=[]) -> None:

from garak import __version__, __description__
from garak import _config
from garak.exception import GarakException

_config.transient.starttime = datetime.datetime.now()
_config.transient.starttime_iso = _config.transient.starttime.isoformat()
Expand Down Expand Up @@ -512,10 +513,11 @@ def main(arguments=[]) -> None:
"💡 try setting --model_type (--model_name is currently set but not --model_type)"
)
logging.info("nothing to do 🤷")
except KeyboardInterrupt:
except KeyboardInterrupt as e:
msg = "User cancel received, terminating all runs"
logging.exception(e)
logging.info(msg)
print(msg)
except ValueError as e:
logging.error(e)
except (ValueError, GarakException) as e:
logging.exception(e)
print(e)
Loading