@@ -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 > = { } ;
@@ -87,7 +89,12 @@ export const provideRobotClientsContext = (
8789 }
8890 } ) ;
8991
90- await client . dial ( config ) ;
92+ try {
93+ await client . dial ( config ) ;
94+ errors [ partID ] = undefined ;
95+ } catch ( nextError ) {
96+ errors [ partID ] = nextError as Error ;
97+ }
9198
9299 connectionStatus [ partID ] = MachineConnectionEvent . CONNECTED ;
93100 } catch ( error ) {
@@ -98,6 +105,7 @@ export const provideRobotClientsContext = (
98105
99106 $effect ( ( ) => {
100107 const configs = dialConfigs ( ) ;
108+ console . log ( configs ) ;
101109
102110 const { added, removed, unchanged } = comparePartIds (
103111 Object . keys ( configs ) ,
@@ -139,6 +147,9 @@ export const provideRobotClientsContext = (
139147 get current ( ) {
140148 return clients ;
141149 } ,
150+ get errors ( ) {
151+ return errors ;
152+ } ,
142153 } ) ;
143154
144155 setContext < ConnectionStatusContext > ( connectionKey , {
0 commit comments