From 4f87ee26e95a7bc5e607114b1e5a62f258d3e927 Mon Sep 17 00:00:00 2001 From: Max Marrone Date: Tue, 12 Sep 2023 15:42:33 -0400 Subject: [PATCH] fix(app,robot-server): Display less error barf (#13495) * Omit errorInfo. * Flesh out ErrorOccurrence documentation. --- .../errors/error_occurrence.py | 46 +++++++++++++++++-- .../Devices/ProtocolRun/RunFailedModal.tsx | 6 --- .../RunningProtocol/RunFailedModal.tsx | 6 --- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/api/src/opentrons/protocol_engine/errors/error_occurrence.py b/api/src/opentrons/protocol_engine/errors/error_occurrence.py index 630413481d1..12f1289f4f0 100644 --- a/api/src/opentrons/protocol_engine/errors/error_occurrence.py +++ b/api/src/opentrons/protocol_engine/errors/error_occurrence.py @@ -37,17 +37,55 @@ def from_failed( ) id: str = Field(..., description="Unique identifier of this error occurrence.") - errorType: str = Field(..., description="Specific error type that occurred.") createdAt: datetime = Field(..., description="When the error occurred.") - detail: str = Field(..., description="A human-readable message about the error.") + errorCode: str = Field( default=ErrorCodes.GENERAL_ERROR.value.code, - description="An enumerated error code for the error type.", + description=( + "An enumerated error code for the error type." + " This is intended to be shown to the robot operator to direct them to the" + " correct rough area for troubleshooting." + ), + ) + + # TODO(mm, 2023-09-07): + # The Opentrons App and Flex ODD use `errorType` in the title of error modals, but it's unclear + # if they should. Is this field redundant now that we have `errorCode` and `detail`? + # + # In practice, this is often the source code name of our Python exception type. + # Should we derive this from `errorCode` instead? Like how HTTP code 404 is always "not found." + errorType: str = Field( + ..., + description=( + "A short name for the error type that occurred, like `PipetteOverpressure`." + " This can be a bit more specific than `errorCode`." + ), ) + + detail: str = Field( + ..., + description=( + "A short human-readable message about the error." + "\n\n" + "This is intended to provide the robot operator with more specific details than" + " `errorCode` alone. It should be no longer than a couple of sentences," + " and it should not contain internal newlines or indentation." + "\n\n" + " It should not internally repeat `errorCode`, but it may internally repeat `errorType`" + " if it helps the message make sense when it's displayed in its own separate block." + ), + ) + errorInfo: Dict[str, str] = Field( default={}, - description="Specific details about the error that may be useful for determining cause.", + description=( + "Specific details about the error that may be useful for determining cause." + " This might contain the same information as `detail`, but in a more structured form." + " It might also contain additional information that was too verbose or technical" + " to put in `detail`." + ), ) + wrappedErrors: List["ErrorOccurrence"] = Field( default=[], description="Errors that may have caused this one." ) diff --git a/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx b/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx index e779e339092..8a3416e5e51 100644 --- a/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx +++ b/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx @@ -1,5 +1,4 @@ import * as React from 'react' -import isEmpty from 'lodash/isEmpty' import { useTranslation } from 'react-i18next' import { ALIGN_CENTER, @@ -95,11 +94,6 @@ export function RunFailedModal({ {highestPriorityError.detail} - {!isEmpty(highestPriorityError.errorInfo) && ( - - {JSON.stringify(highestPriorityError.errorInfo)} - - )} {t('run_failed_modal_description_desktop')} diff --git a/app/src/organisms/OnDeviceDisplay/RunningProtocol/RunFailedModal.tsx b/app/src/organisms/OnDeviceDisplay/RunningProtocol/RunFailedModal.tsx index e1246d836e8..95ce2efcd28 100644 --- a/app/src/organisms/OnDeviceDisplay/RunningProtocol/RunFailedModal.tsx +++ b/app/src/organisms/OnDeviceDisplay/RunningProtocol/RunFailedModal.tsx @@ -1,7 +1,6 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' import { useHistory } from 'react-router-dom' -import isEmpty from 'lodash/isEmpty' import { css } from 'styled-components' import { @@ -98,11 +97,6 @@ export function RunFailedModal({ {highestPriorityError.detail} - {!isEmpty(highestPriorityError.errorInfo) && ( - - {JSON.stringify(highestPriorityError.errorInfo)} - - )}