Skip to content

Commit

Permalink
[dagit] Add error handling to Asset "Rematerialize Partitions" modal (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Mar 11, 2022
1 parent 06f6fa8 commit 5d5d2b0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import {useHistory} from 'react-router-dom';
import * as yaml from 'yaml';

import {AppContext} from '../../app/AppContext';
import {showCustomAlert} from '../../app/CustomAlertProvider';
import {SharedToaster} from '../../app/DomUtils';
import {PythonErrorInfo} from '../../app/PythonErrorInfo';
import {displayNameForAssetKey} from '../../app/Util';
import {PartitionHealthSummary, usePartitionHealthData} from '../../assets/PartitionHealthSummary';
import {AssetKey} from '../../assets/types';
Expand Down Expand Up @@ -109,10 +111,15 @@ export const LaunchAssetChoosePartitionsDialog: React.FC<{
setLaunching(true);

if (!partitionSet) {
SharedToaster.show({
message: 'No partition set was found on the job for this asset graph',
icon: 'error',
intent: 'danger',
const error =
partitionSetsData?.partitionSetsOrError.__typename === 'PythonError'
? partitionSetsData.partitionSetsOrError
: {message: 'No details provided.'};

setLaunching(false);
showCustomAlert({
title: `Unable to find partition set on ${assetJobName}`,
body: <PythonErrorInfo error={error} />,
});
return;
}
Expand Down Expand Up @@ -144,15 +151,26 @@ export const LaunchAssetChoosePartitionsDialog: React.FC<{

const {partition} = tagAndConfigData.partitionSetOrError;

let tags: {key: string; value: string}[] = [];
if (partition.tagsOrError.__typename !== 'PythonError') {
tags = [...partition.tagsOrError.results];
if (partition.tagsOrError.__typename === 'PythonError') {
setLaunching(false);
showCustomAlert({
title: 'Unable to load tags',
body: <PythonErrorInfo error={partition.tagsOrError} />,
});
return;
}
let runConfigData = {};
if (partition.runConfigOrError.__typename !== 'PythonError') {
runConfigData = yaml.parse(partition.runConfigOrError.yaml || '') || {};
if (partition.runConfigOrError.__typename === 'PythonError') {
setLaunching(false);
showCustomAlert({
title: 'Unable to load tags',
body: <PythonErrorInfo error={partition.runConfigOrError} />,
});
return;
}

const tags = [...partition.tagsOrError.results];
const runConfigData = yaml.parse(partition.runConfigOrError.yaml || '') || {};

const launchResult = await client.mutate<
LaunchPipelineExecution,
LaunchPipelineExecutionVariables
Expand Down Expand Up @@ -328,6 +346,9 @@ const ASSET_JOB_PARTITION_SETS_QUERY = gql`
}
) {
__typename
... on PythonError {
message
}
... on PartitionSets {
__typename
results {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d5d2b0

Please sign in to comment.