Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/plugins/python/regress/plugin_errorstr.py
1532 views
1
import sudo
2
3
4
# The purpose of this class is that all methods you call on its object
5
# raises a PluginError with a message containing the name of the called method.
6
# Eg. if you call "ErrorMsgPlugin().some_method()" it will raise
7
# "Something wrong in some_method"
8
class ErrorMsgPlugin(sudo.Plugin):
9
def __getattr__(self, name):
10
def raiser_func(*args):
11
raise sudo.PluginError("Something wrong in " + name)
12
13
return raiser_func
14
15
16
class ConstructErrorPlugin(sudo.Plugin):
17
def __init__(self, **kwargs):
18
raise sudo.PluginError("Something wrong in plugin constructor")
19
20