Skip to content

Commit

Permalink
fix(app): Do not swallow protocol run errors (#3723)
Browse files Browse the repository at this point in the history
Fixes #1828
  • Loading branch information
mcous committed Jul 15, 2019
1 parent ca58301 commit 73d06d8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 21 deletions.
56 changes: 37 additions & 19 deletions app/src/components/RunLog/SessionAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,60 @@ type Props = {
export default function SessionAlert(props: Props) {
const { sessionStatus, className, onResetClick } = props

const completeMessage = (
<p>
Run complete! <a onClick={onResetClick}>Reset run</a> to run protocol
again.
</p>
)
const pauseMessage = 'Run paused'
const cancelMessage = (
<p>
Run canceled. <a onClick={onResetClick}>Reset run</a> to run protocol
again.
</p>
)

switch (sessionStatus) {
case 'finished':
return (
<AlertItem
type="success"
title={completeMessage}
className={className}
type="success"
title={
<p>
Run complete! <a onClick={onResetClick}>Reset run</a> to run
protocol again.
</p>
}
/>
)

case 'paused':
return (
<AlertItem
type="info"
title={pauseMessage}
className={className}
type="info"
icon={{ name: 'pause-circle' }}
title="Run paused"
/>
)

case 'stopped':
return (
<AlertItem type="warning" title={cancelMessage} className={className} />
<AlertItem
className={className}
type="warning"
title={
<p>
Run canceled. <a onClick={onResetClick}>Reset run</a> to run
protocol again.
</p>
}
/>
)

case 'error':
return (
<AlertItem
className={className}
type="error"
title={
<p>
Run encountered an error. <a onClick={onResetClick}>Reset run</a>{' '}
to run protocol again. Please contact support if you need help
resolving this issue.
</p>
}
/>
)

default:
return null
}
Expand Down
12 changes: 10 additions & 2 deletions app/src/robot/reducer/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function sessionReducer(

function handleSessionUpdate(state: State, action: SessionUpdateAction): State {
const {
payload: { state: sessionState, startTime, lastCommand },
payload: { state: sessionStateUpdate, startTime, lastCommand },
} = action
let { protocolCommandsById } = state

Expand All @@ -144,6 +144,13 @@ function handleSessionUpdate(state: State, action: SessionUpdateAction): State {
}
}

// TODO(mc, 2019-07-15): remove this workaround when API issue is resolved
// https://github.com/Opentrons/opentrons/issues/2994
const sessionState =
state.state === 'stopped' && sessionStateUpdate === 'error'
? 'stopped'
: sessionStateUpdate

return { ...state, state: sessionState, startTime, protocolCommandsById }
}

Expand Down Expand Up @@ -182,8 +189,9 @@ function handleRun(state: State, action: any): State {
function handleRunResponse(state: State, action: any): State {
const { error, payload } = action

if (error)
if (error) {
return { ...state, runRequest: { inProgress: false, error: payload } }
}

return { ...state, runRequest: { inProgress: false, error: null } }
}
Expand Down

0 comments on commit 73d06d8

Please sign in to comment.