diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index 4c1895525..1c8bd0cee 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -300,7 +300,7 @@ class View(collections.Sequence): if f: filt = flowfilter.parse(f) if not filt: - raise exceptions.OptionsError( + raise exceptions.CommandError( "Invalid interception filter: %s" % f ) self.set_filter(filt) diff --git a/test/mitmproxy/addons/test_view.py b/test/mitmproxy/addons/test_view.py index e840eac63..976c14b79 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -123,6 +123,9 @@ def test_filter(): v.toggle_marked() assert len(v) == 4 + with pytest.raises(exceptions.CommandError): + v.set_filter_cmd("~notafilter regex") + v[1].marked = True v.toggle_marked() assert len(v) == 1 @@ -320,6 +323,8 @@ def test_order(): v.set_reversed(False) assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] + with pytest.raises(exceptions.CommandError): + v.set_order("not_an_order") def test_reversed():