File: exception.py

package info (click to toggle)
python-stone 3.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,036 kB
  • sloc: python: 22,311; objc: 498; sh: 23; makefile: 11
file content (26 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (2)
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
class InvalidSpec(Exception):
    """Raise this to indicate there was an error in a specification."""

    def __init__(self, msg, lineno, path=None):
        """
        Args:
            msg: Error message intended for the spec writer to read.
            lineno: The line number the error occurred on.
            path: Path to the spec file with the error.
        """
        super().__init__()
        assert isinstance(msg, str), type(msg)
        assert isinstance(lineno, ((int,), type(None))), type(lineno)
        self.msg = msg
        self.lineno = lineno
        self.path = path

    def __str__(self):
        return repr(self)

    def __repr__(self):
        return 'InvalidSpec({!r}, {!r}, {!r})'.format(
            self.msg,
            self.lineno,
            self.path,
        )