diff --git a/confluent/exceptions.py b/confluent/exceptions.py index d8787d9c..c285b887 100644 --- a/confluent/exceptions.py +++ b/confluent/exceptions.py @@ -3,3 +3,6 @@ class ConfluentException(Exception): class NotFoundException(ConfluentException): pass + +class InvalidArgumentException(ConfluentException): + pass diff --git a/confluent/httpapi.py b/confluent/httpapi.py index debf48dd..2fa3d72d 100644 --- a/confluent/httpapi.py +++ b/confluent/httpapi.py @@ -227,6 +227,10 @@ def resourcehandler(env, start_response): start_response('404 Not found', headers) yield "404 - Request path not recognized" return + except exc.InvalidArgumentException: + start_response('400 Bad Request', headers) + yield '400 - Bad Request' + return start_response('200 OK', headers) if mimetype == 'text/html': for datum in _assemble_html(hdlr, resource, querydict): diff --git a/confluent/messages.py b/confluent/messages.py index d0c54f9f..0611502d 100644 --- a/confluent/messages.py +++ b/confluent/messages.py @@ -3,6 +3,7 @@ # This module implements client/server messages emitted from plugins. # Things are defined here to 'encourage' developers to coordinate information # format. This is also how different data formats are supported +import confluent.exceptions as exc import json class ConfluentMessage(object): @@ -35,11 +36,50 @@ class ConfluentMessage(object): snippet += '