Skip to content

Commit

Permalink
read real 409 conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Sep 6, 2024
1 parent 2aacc28 commit ddbd905
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
assembleSecret,
createNotebook,
createSecret,
K8sStatusError,
mergePatchUpdateNotebook,
updateNotebook,
} from '~/api';
Expand Down Expand Up @@ -56,7 +57,7 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
dataConnection,
canEnablePipelines,
}) => {
const [errorMessage, setErrorMessage] = React.useState('');
const [error, setError] = React.useState<K8sStatusError>();

const {
dashboardConfig: {
Expand Down Expand Up @@ -123,17 +124,17 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
refreshAllProjectData();
navigate(`/projects/${projectName}?section=${ProjectSectionID.WORKBENCHES}`);
};
const handleError = (e: Error) => {
const handleError = (e: K8sStatusError) => {
fireFormTrackingEvent('Workbench Created', {
outcome: TrackingOutcome.submit,
success: false,
error: e.message,
});
setErrorMessage(e.message || 'Error creating workbench');
setError(e);
setCreateInProgress(false);
};
const handleStart = () => {
setErrorMessage('');
setError(undefined);
setCreateInProgress(true);
};

Expand Down Expand Up @@ -281,15 +282,15 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({

return (
<Stack hasGutter>
{errorMessage && (
{error && (
<StackItem>
<Alert
isInline
variant="danger"
title="Error creating workbench"
actionLinks={
// If this is a 409 conflict error
errorMessage.includes('the object has been modified') ? (
error.statusObject.code === 409 ? (
<>
<AlertActionLink
onClick={() =>
Expand All @@ -309,7 +310,7 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
) : undefined
}
>
{errorMessage}
{error.message}
</Alert>
</StackItem>
)}
Expand Down

0 comments on commit ddbd905

Please sign in to comment.