|
4 | 4 | ################################################################### |
5 | 5 |
|
6 | 6 | import rips |
7 | | -import grpc |
8 | 7 | import tempfile |
9 | 8 |
|
| 9 | + |
10 | 10 | resinsight = rips.Instance.find() |
11 | 11 |
|
12 | 12 | case = None |
13 | 13 |
|
14 | 14 | # Try loading a non-existing case. We should get a grpc.RpcError exception from the server |
15 | 15 | try: |
16 | 16 | case = resinsight.project.load_case("Nonsense") |
17 | | -except grpc.RpcError as e: |
18 | | - print( |
19 | | - "Expected Server Exception Received while loading case: ", e.code(), e.details() |
20 | | - ) |
| 17 | +except rips.RipsError as e: |
| 18 | + print("Expected Server Exception Received while loading case: ", e) |
21 | 19 |
|
22 | | -# Try loading well paths from a non-existing folder. We should get a grpc.RpcError exception from the server |
| 20 | +# Try loading well paths from a non-existing folder. We should get a rips.RipsError exception from the server |
23 | 21 | try: |
24 | 22 | well_path_files = resinsight.project.import_well_paths( |
25 | 23 | well_path_folder="NONSENSE/NONSENSE" |
26 | 24 | ) |
27 | | -except grpc.RpcError as e: |
28 | | - print( |
29 | | - "Expected Server Exception Received while loading wellpaths: ", |
30 | | - e.code(), |
31 | | - e.details(), |
32 | | - ) |
| 25 | +except rips.RipsError as e: |
| 26 | + print("Server Exception Received while loading wellpaths: ", e) |
33 | 27 |
|
34 | 28 | # Try loading well paths from an existing but empty folder. We should get a warning. |
35 | 29 | try: |
|
42 | 36 | print("Should get warnings below") |
43 | 37 | for warning in resinsight.project.warnings(): |
44 | 38 | print(warning) |
45 | | -except grpc.RpcError as e: |
| 39 | +except rips.RipsError as e: |
46 | 40 | print("Unexpected Server Exception caught!!!", e) |
47 | 41 |
|
48 | 42 | case = resinsight.project.case(case_id=0) |
|
54 | 48 | try: |
55 | 49 | case.set_active_cell_property(results, "GENERATED", "POROAPPENDED", 0) |
56 | 50 | print("Everything went well as expected") |
57 | | - except: # Match any exception, but it should not happen |
58 | | - print("Ooops!") |
| 51 | + except Exception as e: # Match any exception, but it should not happen |
| 52 | + print("Ooops!", e) |
59 | 53 |
|
60 | 54 | # Add another value, so this is outside the bounds of the active cell result storage |
61 | 55 | results.append(1.0) |
62 | 56 |
|
63 | | - # This time we should get a grpc.RpcError exception, which is a server side error. |
| 57 | + # This time we should get a rips.RipsError exception. |
64 | 58 | try: |
65 | 59 | case.set_active_cell_property(results, "GENERATED", "POROAPPENDED", 0) |
66 | 60 | print("Everything went well??") |
67 | | - except grpc.RpcError as e: |
68 | | - print("Expected Server Exception Received: ", e) |
| 61 | + except rips.RipsError as e: |
| 62 | + print("Server Exception Received: ", e) |
69 | 63 | except IndexError: |
70 | 64 | print("Got index out of bounds error. This shouldn't happen here") |
71 | 65 |
|
|
77 | 71 | try: |
78 | 72 | case.set_active_cell_property(results, "GENERATED", "POROAPPENDED", 0) |
79 | 73 | print("Everything went well??") |
80 | | - except grpc.RpcError as e: |
| 74 | + except rips.RipsError as e: |
81 | 75 | print("Got unexpected server exception", e, "This should not happen now") |
82 | 76 | except IndexError: |
83 | 77 | print("Got expected index out of bounds error on client side") |
0 commit comments