Return the Exception data in a format for JSON-RPC.
351240
def dumps(self):
        """"""

        error = {'code': self.code,
                 'message': str(self.message)}

        if self.data is not None:
            error['data'] = self.data

        return error
942455
def _JsonDecodeDict(self, data):
    """"""
    rv = {}
    for key, value in data.iteritems():
      if isinstance(key, unicode):
        key = self._TryStr(key)
      if isinstance(value, unicode):
        value = self._TryStr(value)
      elif isinstance(value, list):
        value = self._JsonDecodeList(value)
      rv[key] = value
    if '__pyringe_type_name__' in data:
      # We're looking at a proxyobject
      rv = ProxyObject(rv)
    return rv
1306754
def json_data(self):
        """"""
        return {
            "type": self.type,
            "max_size": self.max_size,
            "full": self.full,
            "role": self.role,
        }
53290
def get_json_response(self):
        
        self.json_response = self.get_response().json()
        if self.json_response is not None:
            error_code = self.json_response.get("errcode", None)
            self.call_status = True if error_code == 0 else False
        return self.json_response
764508
def json_format_dict(self, data, pretty=False):
        '''  '''

        if pretty:
            return json.dumps(data, sort_keys=True, indent=2)
        else:
            return json.dumps(data)
502851
def json_rpc_format(self):
        

        error = {
            'name': smart_text(self.__class__.__name__),
            'code': self.code,
            'message': "%s: %s" %
            (smart_text(self.__class__.__name__), smart_text(self.message)),
            'data': self.data
        }

        from django.conf import settings

        if settings.DEBUG:
            import sys, traceback
            error['stack'] = traceback.format_exc()
            error['executable'] = sys.executable

        return error
1320455
def make_json_error(error):
    
    message = extract_error_message(error)
    status_code = extract_status_code(error)
    context = extract_context(error)
    retryable = extract_retryable(error)
    headers = extract_headers(error)

    # Flask will not log user exception (fortunately), but will log an error
    # for exceptions that escape out of the application entirely (e.g. if the
    # error handler raises an error)
    error_logger.debug("Handling {} error: {}".format(
        status_code,
        message,
    ))

    # Serialize into JSON response
    response_data = {
        "code": status_code,
        "context": context,
        "message": message,
        "retryable": retryable,
    }
    # Don't pass in the error schema because it will suppress any extra fields
    return dump_response_data(None, response_data, status_code, headers)
121861
def json_is_exception(resp):
    
    if not json_is_error(resp):
        return False

    if 'traceback' not in resp.keys() or 'error' not in resp.keys():
        return False

    return True
1078179
def errors_to_json(errors):
    """"""
    out = []
    for e in errors:
        out.append({
            "check": e[0],
            "message": e[1],
            "line": 1 + e[2],
            "column": 1 + e[3],
            "start": 1 + e[4],
            "end": 1 + e[5],
            "extent": e[6],
            "severity": e[7],
            "replacements": e[8],
        })

    return json.dumps(
        dict(status="success", data={"errors": out}), sort_keys=True)
789416
function errorJSON (err) {
  var res = {}
  Object.getOwnPropertyNames(err).forEach(function (key) {
    res[key] = err[key]
  }, err)
  return res
}
1092717
def json_data(self):
        """"""
        return {
            "number": self.number,
            "type": self.type,
            "participant_id": self.participant_id,
            "question": self.question,
            "response": self.response,
        }
189923
def _get_response_json(self, res):
        

        try:
            error = res.json()
        except ValueError:
            error = {
                "message": "The API did not respond with JSON, but: {0}".format(res.text[:1000]),
                "error_code": "{0}".format(res.status_code)
            }
        return error
107429
def format(self, record):
        """"""
        data = record.__dict__.copy()

        data['data_id'] = DATA['id']
        data['data_location_id'] = DATA_LOCATION['id']
        data['hostname'] = socket.gethostname()

        # Get relative path, so listener can reconstruct the path to the actual code.
        data['pathname'] = os.path.relpath(data['pathname'], os.path.dirname(__file__))

        # Exception and Traceback cannot be serialized.
        data['exc_info'] = None

        # Ensure logging message is instantiated to a string.
        data['msg'] = str(data['msg'])

        return json.dumps(data)
978777
def rpc_error(id: Union[str, int], error_msg: str,
              warnings: List[Any] = []) -> rpcq.messages.RPCError:
    
    return rpcq.messages.RPCError(
        jsonrpc='2.0',
        id=id,
        error=error_msg,
        warnings=[rpc_warning(warning) for warning in warnings])
1161150
def render_exception_js(self, exception):
        

        from .http import JsonResponse

        response = {}
        response["error"] = exception.error
        response["error_description"] = exception.reason

        return JsonResponse(response, status=getattr(exception, 'code', 400))
960311
def to_json(self, value):
        """"""
        if not self.is_valid(value):
            raise ex.SerializeException('Invalid value: {}'.format(value))
        return value
1048097
def load(self):
        """"""
        try:
            self._read()
            self._parse()
        except Exception as exc:
            self.failed = True

            params = {'path': self._path, 'exception': exc}
            if self.fail_silently:
                LOG.warning("Error processing message json file '%(path)s': "
                            "%(exception)s", params)
            else:
                raise exceptions.MessageFailure(
                    _("Error processing message json file '%(path)s': "
                      "%(exception)s") % params)