@@ -15,6 +15,7 @@ const dialKey = Symbol('dial-configs-context');
1515
1616interface ClientContext {
1717 current : Record < PartID , Client | undefined > ;
18+ errors : Record < PartID , Error | undefined > ;
1819}
1920
2021interface ConnectionStatusContext {
@@ -30,6 +31,7 @@ export const provideRobotClientsContext = (
3031) => {
3132 const queryClient = useQueryClient ( ) ;
3233 const clients = $state < Record < PartID , Client | undefined > > ( { } ) ;
34+ const errors = $state < Record < PartID , Error | undefined > > ( { } ) ;
3335 const connectionStatus = $state < Record < PartID , MachineConnectionEvent > > ( { } ) ;
3436
3537 let lastConfigs : Record < PartID , DialConf | undefined > = { } ;
@@ -88,10 +90,11 @@ export const provideRobotClientsContext = (
8890 } ) ;
8991
9092 await client . dial ( config ) ;
93+ errors [ partID ] = undefined ;
9194
9295 connectionStatus [ partID ] = MachineConnectionEvent . CONNECTED ;
9396 } catch ( error ) {
94- console . error ( error ) ;
97+ errors [ partID ] = error as Error ;
9598 connectionStatus [ partID ] = MachineConnectionEvent . DISCONNECTED ;
9699 }
97100 } ;
@@ -139,6 +142,9 @@ export const provideRobotClientsContext = (
139142 get current ( ) {
140143 return clients ;
141144 } ,
145+ get errors ( ) {
146+ return errors ;
147+ } ,
142148 } ) ;
143149
144150 setContext < ConnectionStatusContext > ( connectionKey , {
0 commit comments