File: exceptions_example_service.py

package info (click to toggle)
robotraconteur 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 101,380 kB
  • sloc: cpp: 1,149,268; cs: 87,653; java: 58,127; python: 26,897; ansic: 356; sh: 152; makefile: 90; xml: 51
file content (32 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download
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
import RobotRaconteur as RR
RRN = RR.RobotRaconteurNode.s
import numpy as np


class ExceptionExample_impl:
    def my_exception_function1(self):
        raise RR.OperationFailedException("This is an example of an OperationFailedException")

    def my_exception_function2(self):
        exp_type = RRN.GetExceptionType("experimental.exception_example.MyExampleCustomException")
        raise exp_type("This is an example of a custom exception")


def main():
    with RR.ServerNodeSetup("experimental.exception_example", 53224) as node_setup:

        # Register the service type
        RRN.RegisterServiceTypeFromFile("../robdef/experimental.exception_example.robdef")

        # Create the object
        obj = ExceptionExample_impl()

        # Register the service
        RRN.RegisterService("exception_example", "experimental.exception_example.ExceptionExample", obj)

        # Wait for the user to quit
        input("Server started, press enter to quit...")


if __name__ == '__main__':
    main()