diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-25 10:53:29 +1200 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-25 10:55:00 +1200 |
| commit | e7e6a60246c28e1399f0fd626c73b4f16b04a995 (patch) | |
| tree | e3220f7b0c7b63e59a47fc2115a0375afb4250f4 /libpathod | |
| parent | 59f408dcf437b0099edc0b54b73c006752c7dc7e (diff) | |
| download | mitmproxy-e7e6a60246c28e1399f0fd626c73b4f16b04a995.tar.gz mitmproxy-e7e6a60246c28e1399f0fd626c73b4f16b04a995.tar.bz2 mitmproxy-e7e6a60246c28e1399f0fd626c73b4f16b04a995.zip | |
Nicer error for empty preview spec submission.
Diffstat (limited to 'libpathod')
| -rw-r--r-- | libpathod/app.py | 5 | ||||
| -rw-r--r-- | libpathod/templates/request_preview.html | 1 | ||||
| -rw-r--r-- | libpathod/templates/response_preview.html | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/libpathod/app.py b/libpathod/app.py index 17be448d..e93a898f 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -82,12 +82,17 @@ def _preview(is_request): template = "response_preview.html" spec = request.args["spec"] + args = dict( spec = spec, section = "main", syntaxerror = None, error = None ) + if not spec.strip(): + args["error"] = "Can't parse an empty spec." + return render(template, **args) + try: if is_request: r = rparse.parse_request(app.config["pathod"].request_settings, spec) diff --git a/libpathod/templates/request_preview.html b/libpathod/templates/request_preview.html index fe8a03e9..eaf78898 100644 --- a/libpathod/templates/request_preview.html +++ b/libpathod/templates/request_preview.html @@ -7,7 +7,6 @@ <h2> Error: {{ syntaxerror }} </h2> <pre>{{ marked }}</pre> {% elif error %} - <h2> Error </h2> <p style="color: #ff0000">{{ error }}</p> {% else %} <h2>Spec:</h2> diff --git a/libpathod/templates/response_preview.html b/libpathod/templates/response_preview.html index 1b44e480..2e1abcf4 100644 --- a/libpathod/templates/response_preview.html +++ b/libpathod/templates/response_preview.html @@ -7,7 +7,6 @@ <h2> Error: {{ syntaxerror }} </h2> <pre>{{ marked }}</pre> {% elif error %} - <h2> Error </h2> <p style="color: #ff0000">{{ error }}</p> {% else %} <h2>Spec:</h2> |
