Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): add error handling for failed maintenance run creation #16818

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/src/organisms/GripperWizardFlows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function GripperWizardFlows(
const [createdMaintenanceRunId, setCreatedMaintenanceRunId] = useState<
string | null
>(null)
const [errorMessage, setErrorMessage] = useState<null | string>(null)

// we should start checking for run deletion only after the maintenance run is created
// and the useCurrentRun poll has returned that created id
Expand All @@ -86,6 +87,9 @@ export function GripperWizardFlows(
onSuccess: response => {
setCreatedMaintenanceRunId(response.data.id)
},
onError: error => {
setErrorMessage(error.message)
},
})

const { data: maintenanceRunData } = useNotifyCurrentMaintenanceRun({
Expand Down Expand Up @@ -117,7 +121,6 @@ export function GripperWizardFlows(
])

const [isExiting, setIsExiting] = useState<boolean>(false)
const [errorMessage, setErrorMessage] = useState<null | string>(null)

const handleClose = (): void => {
if (props?.onComplete != null) {
Expand Down Expand Up @@ -298,9 +301,12 @@ export const GripperWizard = (
isRobotMoving={isRobotMoving}
/>
)
} else if (
}
// These flows often have custom error messaging, so this fallback modal is shown only in specific circumstances.
else if (
(isExiting && errorMessage != null) ||
maintenanceRunStatus === RUN_STATUS_FAILED
maintenanceRunStatus === RUN_STATUS_FAILED ||
(errorMessage != null && createdMaintenanceRunId == null)
) {
onExit = handleClose
modalContent = (
Expand Down
9 changes: 7 additions & 2 deletions app/src/organisms/PipetteWizardFlows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const PipetteWizardFlows = (
const [createdMaintenanceRunId, setCreatedMaintenanceRunId] = useState<
string | null
>(null)
const [errorMessage, setShowErrorMessage] = useState<null | string>(null)
// we should start checking for run deletion only after the maintenance run is created
// and the useCurrentRun poll has returned that created id
const [
Expand Down Expand Up @@ -143,6 +144,9 @@ export const PipetteWizardFlows = (
onSuccess: response => {
setCreatedMaintenanceRunId(response.data.id)
},
onError: error => {
setShowErrorMessage(error.message)
},
},
host
)
Expand All @@ -169,7 +173,6 @@ export const PipetteWizardFlows = (
closeFlow,
])

const [errorMessage, setShowErrorMessage] = useState<null | string>(null)
const [isExiting, setIsExiting] = useState<boolean>(false)
const proceed = (): void => {
if (!isCommandMutationLoading) {
Expand Down Expand Up @@ -281,9 +284,11 @@ export const PipetteWizardFlows = (
let onExit
if (currentStep == null) return null
let modalContent: JSX.Element = <div>UNASSIGNED STEP</div>
// These flows often have custom error messaging, so this fallback modal is shown only in specific circumstances.
if (
(isExiting && errorMessage != null) ||
maintenanceRunData?.data.status === RUN_STATUS_FAILED
maintenanceRunData?.data.status === RUN_STATUS_FAILED ||
(errorMessage != null && createdMaintenanceRunId == null)
) {
modalContent = (
<SimpleWizardBody
Expand Down
Loading