File: excep.py

package info (click to toggle)
pyro4 4.82-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 2,528 kB
  • sloc: python: 17,736; makefile: 169; sh: 113; javascript: 62
file content (38 lines) | stat: -rw-r--r-- 810 bytes parent folder | download | duplicates (3)
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
import pickle
import Pyro4


class UnserializableError(Exception):
    def __reduce__(self):
        raise pickle.PicklingError("make this nonpickleable")


@Pyro4.expose
class TestClass(object):
    def div(self, arg1, arg2):
        return arg1 / arg2

    def error(self):
        raise ValueError('a valueerror! Great!')

    def error2(self):
        return ValueError('a valueerror! Great!')

    def othererr(self):
        raise RuntimeError('a runtime error!')

    def complexerror(self):
        x = Foo()
        x.crash()

    def unserializable(self):
        raise UnserializableError("this error can't be serialized")


class Foo(object):
    def crash(self):
        self.crash2('going down...')

    def crash2(self, arg):
        # this statement will crash on purpose:
        x = arg // 2