11"""Policy management section for the Data Platform Toolbox."""
22
33import streamlit as st
4- import grpc
4+ from grpclib . exceptions import GRPCError
55from dp_sdk .ocf import dp
66
77
@@ -41,9 +41,9 @@ async def policies_section(admin_client, data_client):
4141 response_dict = response .to_dict ()
4242 st .success (f"✅ Policy Group '{ new_policy_group_name } ' created!" )
4343 st .write (response_dict )
44- except grpc . RpcError as e :
44+ except GRPCError as e :
4545 st .error (
46- f"❌ gRPC Error: { e .details () if hasattr ( e , 'details' ) else str ( e ) } "
46+ f"❌ gRPC Error: { e .message } "
4747 )
4848 except Exception as e :
4949 st .error (f"❌ Error creating policy group: { str (e )} " )
@@ -70,9 +70,9 @@ async def policies_section(admin_client, data_client):
7070 st .success (f"✅ Found policy group: { policy_group_name } " )
7171 st .write (response_dict )
7272
73- except grpc . RpcError as e :
73+ except GRPCError as e :
7474 st .error (
75- f"❌ gRPC Error: { e .details () if hasattr ( e , 'details' ) else str ( e ) } "
75+ f"❌ gRPC Error: { e .message } "
7676 )
7777 except Exception as e :
7878 st .error (f"❌ Error fetching policy group: { str (e )} " )
@@ -137,9 +137,9 @@ async def policies_section(admin_client, data_client):
137137 )
138138 )
139139 st .success (f"✅ Policy added to group '{ add_policy_group } '!" )
140- except grpc . RpcError as e :
140+ except GRPCError as e :
141141 st .error (
142- f"❌ gRPC Error: { e .details () if hasattr ( e , 'details' ) else str ( e ) } "
142+ f"❌ gRPC Error: { e .message } "
143143 )
144144 except Exception as e :
145145 st .error (f"❌ Error adding policy: { str (e )} " )
@@ -207,9 +207,9 @@ async def policies_section(admin_client, data_client):
207207 )
208208 )
209209 st .success (f"✅ Policy removed from group '{ remove_policy_group } '!" )
210- except grpc . RpcError as e :
210+ except GRPCError as e :
211211 st .error (
212- f"❌ gRPC Error: { e .details () if hasattr ( e , 'details' ) else str ( e ) } "
212+ f"❌ gRPC Error: { e .message } "
213213 )
214214 except Exception as e :
215215 st .error (f"❌ Error removing policy: { str (e )} " )
@@ -236,9 +236,9 @@ async def policies_section(admin_client, data_client):
236236 st .success (
237237 f"✅ Policy group '{ add_pg_name } ' added to organisation '{ add_pg_org } '!"
238238 )
239- except grpc . RpcError as e :
239+ except GRPCError as e :
240240 st .error (
241- f"❌ gRPC Error: { e .details () if hasattr ( e , 'details' ) else str ( e ) } "
241+ f"❌ gRPC Error: { e .message } "
242242 )
243243 except Exception as e :
244244 st .error (f"❌ Error adding policy group to organisation: { str (e )} " )
@@ -273,9 +273,9 @@ async def policies_section(admin_client, data_client):
273273 st .success (
274274 f"✅ Policy group '{ remove_policy_group_name } ' removed from organisation '{ remove_policy_group_org } '!"
275275 )
276- except grpc . RpcError as e :
276+ except GRPCError as e :
277277 st .error (
278- f"❌ gRPC Error: { e .details () if hasattr ( e , 'details' ) else str ( e ) } "
278+ f"❌ gRPC Error: { e .message } "
279279 )
280280 except Exception as e :
281281 st .error (f"❌ Error removing policy group from organisation: { str (e )} " )
0 commit comments