From 13ccdb4df1395439d4d74867f741ddbe0bcb395c Mon Sep 17 00:00:00 2001 From: Arksine Date: Fri, 5 Mar 2021 15:10:53 -0500 Subject: [PATCH] app: raise a clear exception when request arguments fail to parse This error is an indication that a JSON body was sent without the content type set to "application/json". Signed-off-by: Eric Callahan --- moonraker/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/moonraker/app.py b/moonraker/app.py index deb76b3..323f3eb 100644 --- a/moonraker/app.py +++ b/moonraker/app.py @@ -297,7 +297,12 @@ class DynamicRequestHandler(AuthorizedRequestHandler): return {'objects': args} def parse_args(self): - args = self._parse_query() + try: + args = self._parse_query() + except Exception: + raise ServerError( + "Error Parsing Request Arguments. " + "Is the Content-Type correct?") content_type = self.request.headers.get('Content-Type', "").strip() if content_type.startswith("application/json"): try: