def make_response(resp):
    """ Returns Flask tuple `resp, code` code per http://flask.pocoo.org/docs/0.10/quickstart/#about-responses
    """
    if 'errorMsg' in resp:
        # Error 162 pertains to "Historical data request pacing violation"
        if resp['errorCode'] in [None, 162]:
            return resp, 429
        # Bad request if arg which made it to TWS wasn't right
        return resp, 400
    else:
        return resp