summaryrefslogtreecommitdiff
path: root/src/flake8/exceptions.py
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-07-27 07:17:29 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-07-27 07:17:29 -0500
commit47e3e65cc1734e46fd16ea11622e57b7978d3e0d (patch)
treea7bf86b9e26ed8f0f9d5fe8553abe585b3c80556 /src/flake8/exceptions.py
parent846bfafe6c63870f41bac0eadf41b2a0a85c85aa (diff)
downloadflake8-47e3e65cc1734e46fd16ea11622e57b7978d3e0d.tar.gz
Handle AttributeErrors during parameter aggregation
Plugins do not have their parameters checked in advance, so when we try to aggregate parameters for a plugin, there's a chance it may request an attribute of the FileProcessor that simply does not exist. We catch this and re-raise it but we should also capture it in the checker manager and handle it appropriately there as well.
Diffstat (limited to 'src/flake8/exceptions.py')
-rw-r--r--src/flake8/exceptions.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/flake8/exceptions.py b/src/flake8/exceptions.py
index 2b03795..71738b2 100644
--- a/src/flake8/exceptions.py
+++ b/src/flake8/exceptions.py
@@ -49,6 +49,26 @@ class InvalidSyntax(Flake8Exception):
super(InvalidSyntax, self).__init__(*args, **kwargs)
+class PluginRequestedUnknownParameters(Flake8Exception):
+ """The plugin requested unknown parameters."""
+
+ FORMAT = '"%(name)s" requested unknown parameters causing %(exc)s'
+
+ def __init__(self, *args, **kwargs):
+ """Pop certain keyword arguments for initialization."""
+ self.original_exception = kwargs.pop('exception')
+ self.plugin = kwargs.pop('plugin')
+ super(PluginRequestedUnknownParameters, self).__init__(
+ *args,
+ **kwargs
+ )
+
+ def __str__(self):
+ """Format our exception message."""
+ return self.FORMAT % {'name': self.plugin.plugin_name,
+ 'exc': self.original_exception}
+
+
class HookInstallationError(Flake8Exception):
"""Parent exception for all hooks errors."""