File: exc.py

package info (click to toggle)
python-tinyrpc 0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 324 kB
  • sloc: python: 1,700; makefile: 142; sh: 16
file content (40 lines) | stat: -rw-r--r-- 1,239 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# -*- coding: utf-8 -*-

class RPCError(Exception):
    """Base class for all excetions thrown by :py:mod:`tinyrpc`."""


class BadRequestError(RPCError):
    """Base class for all errors that caused the processing of a request to
    abort before a request object could be instantiated."""

    def error_respond(self):
        """Create :py:class:`~tinyrpc.RPCErrorResponse` to respond the error.

        :return: A error responce instance or ``None``, if the protocol decides
                 to drop the error silently."""
        raise RuntimeError('Not implemented')


class BadReplyError(RPCError):
    """Base class for all errors that caused processing of a reply to abort
    before it could be turned in a response object."""


class InvalidRequestError(BadRequestError):
    """A request made was malformed (i.e. violated the specification) and could
    not be parsed."""


class InvalidReplyError(BadReplyError):
    """A reply received was malformed (i.e. violated the specification) and
    could not be parsed into a response."""


class MethodNotFoundError(RPCError):
    """The desired method was not found."""


class ServerError(RPCError):
    """An internal error in the RPC system occured."""