@@ -4,11 +4,13 @@ import head from 'lodash/head'
44import {
55 useResumeRunFromRecoveryMutation ,
66 useStopRunMutation ,
7- useUpdateErrorRecoveryPolicy ,
87 useResumeRunFromRecoveryAssumingFalsePositiveMutation ,
98} from '@opentrons/react-api-client'
109
11- import { useChainRunCommands } from '/app/resources/runs'
10+ import {
11+ useChainRunCommands ,
12+ useUpdateRecoveryPolicyWithStrategy ,
13+ } from '/app/resources/runs'
1214import { DEFINED_ERROR_TYPES , ERROR_KINDS , RECOVERY_MAP } from '../constants'
1315import { getErrorKind } from '/app/organisms/ErrorRecoveryFlows/utils'
1416
@@ -23,12 +25,7 @@ import type {
2325 PrepareToAspirateRunTimeCommand ,
2426 MoveLabwareParams ,
2527} from '@opentrons/shared-data'
26- import type {
27- CommandData ,
28- IfMatchType ,
29- RecoveryPolicyRulesParams ,
30- RunAction ,
31- } from '@opentrons/api-client'
28+ import type { CommandData , IfMatchType , RunAction } from '@opentrons/api-client'
3229import type { WellGroup } from '@opentrons/components'
3330import type { FailedCommand , RecoveryRoute , RouteStep } from '../types'
3431import type { UseFailedLabwareUtilsResult } from './useFailedLabwareUtils'
@@ -38,6 +35,7 @@ import type { UseRecoveryAnalyticsResult } from '/app/redux-resources/analytics'
3835import type { CurrentRecoveryOptionUtils } from './useRecoveryRouting'
3936import type { ErrorRecoveryFlowsProps } from '..'
4037import type { FailedCommandBySource } from './useRetainedFailedCommandBySource'
38+ import type { UpdateErrorRecoveryPolicyWithStrategy } from '/app/resources/runs'
4139
4240interface UseRecoveryCommandsParams {
4341 runId : string
@@ -100,9 +98,7 @@ export function useRecoveryCommands({
10098 mutateAsync : resumeRunFromRecoveryAssumingFalsePositive ,
10199 } = useResumeRunFromRecoveryAssumingFalsePositiveMutation ( )
102100 const { stopRun } = useStopRunMutation ( )
103- const {
104- mutateAsync : updateErrorRecoveryPolicy ,
105- } = useUpdateErrorRecoveryPolicy ( runId )
101+ const updateErrorRecoveryPolicy = useUpdateRecoveryPolicyWithStrategy ( runId )
106102 const { makeSuccessToast } = recoveryToastUtils
107103
108104 // TODO(jh, 11-21-24): Some commands return a 200 with an error body. We should catch these and propagate the error.
@@ -231,10 +227,12 @@ export function useRecoveryCommands({
231227 ifMatch
232228 )
233229
234- return updateErrorRecoveryPolicy ( ignorePolicyRules )
230+ return updateErrorRecoveryPolicy ( ignorePolicyRules , 'append' )
235231 . then ( ( ) => Promise . resolve ( ) )
236- . catch ( ( ) =>
237- Promise . reject ( new Error ( 'Failed to update recovery policy.' ) )
232+ . catch ( ( e : Error ) =>
233+ Promise . reject (
234+ new Error ( `Failed to update recovery policy: ${ e . message } ` )
235+ )
238236 )
239237 } else {
240238 void proceedToRouteAndStep ( RECOVERY_MAP . ERROR_WHILE_RECOVERING . ROUTE )
@@ -421,12 +419,8 @@ export const buildIgnorePolicyRules = (
421419 commandType : FailedCommand [ 'commandType' ] ,
422420 errorType : string ,
423421 ifMatch : IfMatchType
424- ) : RecoveryPolicyRulesParams => {
425- return [
426- {
427- commandType,
428- errorType,
429- ifMatch,
430- } ,
431- ]
432- }
422+ ) : UpdateErrorRecoveryPolicyWithStrategy [ 'newPolicy' ] => ( {
423+ commandType,
424+ errorType,
425+ ifMatch,
426+ } )
0 commit comments