Formats a JSON-RPC error as a dict with keys: 'jsonrpc', 'id', 'error'

def err_response(reqid, code, msg, data=None):
    """
    Formats a JSON-RPC error as a dict with keys: 'jsonrpc', 'id', 'error'
    """
    err = { "code": code, "message": msg }
    if data:
        err["data"] = data
    return { "jsonrpc": "2.0", "id": reqid, "error": err }