Called to decode queries when no handler for that mode is found.

        @raises ProtocolError: This implementation always raises
            L{ProtocolError}.
965670
def defaultDecoder(self, message, server):
        
        mode = message.getArg(OPENID_NS, 'mode')
        fmt = "Unrecognized OpenID mode %r"
        raise ProtocolError(message, text=fmt % (mode,))
1097360
def decode_bottom_up
      loop do
        last_known_hdr = last_header
        break if !last_known_hdr.respond_to?(:body) || last_known_hdr.body.empty?

        nh = search_upper_header(last_known_hdr)
        break if nh.nil?

        nheader = nh.new(packet: self)
        nheader = nheader.read(last_known_hdr.body)
        next unless nheader.parse?

        add_header nheader, parsing: true
        break if last_header == last_known_hdr
      end
    end
86443
def parse(self, input):
        """"""
        query = None
        for handler in self._line_handlers:
            try:
                query = handler.handle(input)
            except Exception as e:
                query = None
            finally:
                if query is not None:
                    return query
        return None
777451
def decode(self, charset='utf-8', errors='replace'):
        
        return URL(
            self.scheme.decode('ascii'),
            self.decode_netloc(),
            self.path.decode(charset, errors),
            self.query.decode(charset, errors),
            self.fragment.decode(charset, errors)
        )
239320
def handler_for(rjr_method)
    # look for exact match first
    handler = @handlers.find { |k,v| k == rjr_method }

    # if not found try to match regex's
    handler ||= @handlers.find { |k,v| k.is_a?(Regexp) && (k =~ rjr_method) }

    handler.nil? ? nil : handler.last
  end
789305
def default_match_error_handler(exc):
    
    if isinstance(exc, NotFound):
        return http.NotFound()
    elif isinstance(exc, MethodNotAllowed):
        return http.MethodNotAllowed()
    elif isinstance(exc, RequestRedirect):
        return redirect(exc.new_url)
    else:
        raise exc
992326
def clean_protocol(self, protocol):
        
        if protocol is not None:
            try:
                return self.PROTOCOL_MAP[protocol]
            except KeyError:
                self._handle_malformation(
                    '"{protocol}" is not a recognised protocol'.format(
                        protocol=protocol
                    )
                )
1275653
def surrogateescape_handler(exc):
    
    mystring = exc.object[exc.start:exc.end]

    try:
        if isinstance(exc, UnicodeDecodeError):
            # mystring is a byte-string in this case
            decoded = replace_surrogate_decode(mystring)
        elif isinstance(exc, UnicodeEncodeError):
            # In the case of u'\udcc3'.encode('ascii',
            # 'this_surrogateescape_handler'), both Python 2.x and 3.x raise an
            # exception anyway after this function is called, even though I think
            # it's doing what it should. It seems that the strict encoder is called
            # to encode the unicode string that this function returns ...
            decoded = replace_surrogate_encode(mystring, exc)
        else:
            raise exc
    except NotASurrogateError:
        raise exc
    return (decoded, exc.end)
203917
def logic(self, data):
        
        try:
            msg = Message(data, self)
            msg.validate(self.protocol_version)
        except (ValueError, vol.Invalid) as exc:
            _LOGGER.warning('Not a valid message: %s', exc)
            return None

        message_type = self.const.MessageType(msg.type)
        handler = message_type.get_handler(self.handlers)
        ret = handler(msg)
        ret = self._route_message(ret)
        ret = ret.encode() if ret else None
        return ret
41966
def _decode_request(self, encoded_request):
        """"""
        obj = self.serializer.loads(encoded_request)
        return request_from_dict(obj, self.spider)
183257
def _request(self, method, url, query_or_data=None, **kwargs):
        

        if query_or_data is None:
            query_or_data = {}

        request_method = getattr(self, '_http_{0}'.format(method))
        response = retry_request(self)(request_method)(url, query_or_data, **kwargs)

        if self.raw_mode:
            return response

        if response.status_code >= 300:
            error = get_error(response)
            if self.raise_errors:
                raise error
            return error

        # Return response object on NoContent
        if response.status_code == 204 or not response.text:
            return response

        return ResourceBuilder(
            self,
            self.default_locale,
            response.json()
        ).build()
1098919
def handle_single(req)
      method = req["method"]
      if !method
        return err_resp(req, -32600, "No method provided on request")
      end

      # Special case - client is requesting the IDL bound to this server, so
      # we return it verbatim.  No further validation is needed in this case.
      if method == "barrister-idl"
        return ok_resp(req, @contract.idl)
      end

      # Make sure we can find an interface and function on the IDL for this
      # request method string
      err_resp, iface, func = @contract.resolve_method(req)
      if err_resp != nil
        return err_resp
      end
      
      # Make sure that the params on the request match the IDL types
      err_resp = @contract.validate_params(req, func)
      if err_resp != nil
        return err_resp
      end
      
      params = [ ]
      if req["params"]
        params = req["params"]
      end

      # Make sure we have a handler bound to this Server for the interface.
      # If not, that means `server.add_handler` was not called for this interface
      # name.  That's likely a misconfiguration.
      handler = @handlers[iface.name]
      if !handler
        return err_resp(req, -32000, "Server error. No handler is bound to interface #{iface.name}")
      end

      # Make sure that the handler has a method for the given function.
      if !handler.respond_to?(func.name)
        return err_resp(req, -32000, "Server error. Handler for #{iface.name} does not implement #{func.name}")
      end

      begin 
        # Call the handler function. This is where your code gets invoked.
        result  = handler.send(func.name, *params)
        
        # Verify that the handler function's return value matches the
        # correct type as specified in the IDL
        err_resp = @contract.validate_result(req, result, func)
        if err_resp != nil
            return err_resp
        else
          return ok_resp(req, result)
        end
      rescue RpcException => e
        # If the handler raised a RpcException, that's ok - return it unmodified.
        return err_resp(req, e.code, e.message, e.data)
      rescue => e
        # If any other error was raised, print it and return a generic error to the client
        puts e.inspect
        puts e.backtrace
        return err_resp(req, -32000, "Unknown error: #{e}")
      end
    end
420270
def decode_cursor(self, request):
        
        # Determine if we have a cursor, and if so then decode it.
        encoded = request.query_params.get(self.cursor_query_param)
        if encoded is None:
            return None

        try:
            querystring = b64decode(encoded.encode('ascii')).decode('ascii')
            tokens = urlparse.parse_qs(querystring, keep_blank_values=True)

            offset = tokens.get('o', ['0'])[0]
            offset = _positive_int(offset, cutoff=self.offset_cutoff)

            reverse = tokens.get('r', ['0'])[0]
            reverse = bool(int(reverse))

            # The difference. Don't get just the 0th entry: get all entries.
            position = tokens.get('p', None)
        except (TypeError, ValueError):
            raise NotFound(self.invalid_cursor_message)

        return Cursor(offset=offset, reverse=reverse, position=position)
1168502
def error(message)
      length = (position > 0 ? Tokenizer.query(symbols[0..(position - 1)]).size + 1 : 0)
      raise "parsing query failed\n#{message}\n\n#{Tokenizer.query(symbols)}\n#{' ' * length}^"
    rescue
      logger.error $!
      raise $!
    end
430670
def refresh_existing_encodings(self):
        
        update = False

        for msg in self.proto_analyzer.messages:
            i = next((i for i, d in enumerate(self.decodings) if d.name == msg.decoder.name), 0)
            if msg.decoder != self.decodings[i]:
                update = True
                msg.decoder = self.decodings[i]
                msg.clear_decoded_bits()
                msg.clear_encoded_bits()

        if update:
            self.protocol_model.update()
            self.label_value_model.update()
429639
def resolve_remote(uri, handlers):
    
    scheme = urlparse.urlsplit(uri).scheme
    if scheme in handlers:
        result = handlers[scheme](uri)
    else:
        req = urlopen(uri)
        encoding = req.info().get_content_charset() or 'utf-8'
        result = json.loads(req.read().decode(encoding),)
    return result
671103
function handleQueryError (err) {

        queryErrorCount++;

        // Something has gone terribly wrong. Break from loop.
        if (queryErrorCount > 1) {

            // Reset all filters.
            session.list.formData = {};

            // Notify the user that an error has occured.
            req.linz.notifications.push(linz.api.views.notification({
                text: 'One of the filters is repeatedly generating an error. All filters have been removed.',
                type: 'error'
            }));

            // Rerun the query at the last known working state.
            // eslint-disable-next-line no-use-before-define
            return getModelIndex();

        }

        // Reset the last known working state.
        session.list.formData = session.list.previous.formData;

        // If we're in development mode, return the error
        // so that the developers are aware of it and can fix it.
        if (isDevelopment) {
            return next(err);
        }

        // Notify the user that an error has occured.
        req.linz.notifications.push(linz.api.views.notification({
            text: 'An error has occured with one of the filters you added. It has been removed.',
            type: 'error'
        }));

        // Rerun the query at the last known working state.
        // eslint-disable-next-line no-use-before-define
        return getModelIndex();

    }