Skip to content

Commit 3c95a71

Browse files
arthurdennerCompuIves
authored andcommitted
fix(deployments): display error messages from ZEIT Now (codesandbox#3023)
1 parent eaa04d8 commit 3c95a71

File tree

1 file changed

+14
-10
lines changed
  • packages/app/src/app/overmind/namespaces/deployment

1 file changed

+14
-10
lines changed

packages/app/src/app/overmind/namespaces/deployment/actions.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import { AxiosError } from 'axios';
2+
import { get } from 'lodash-es';
13
import { Action, AsyncAction } from 'app/overmind';
24
import * as internalActions from './internalActions';
35

46
export const internal = internalActions;
57

8+
const getZeitErrorMessage = (error: AxiosError) =>
9+
get(
10+
error,
11+
'response.data.error.message',
12+
'An unknown error occurred when connecting to ZEIT'
13+
);
14+
615
export const deployWithNetlify: AsyncAction = async ({
716
effects,
817
actions,
@@ -67,9 +76,7 @@ export const getDeploys: AsyncAction = async ({ state, effects }) => {
6776
zeitConfig.name
6877
);
6978
} catch (error) {
70-
effects.notificationToast.error(
71-
'An unknown error occurred when connecting to ZEIT'
72-
);
79+
effects.notificationToast.error(getZeitErrorMessage(error));
7380
}
7481

7582
state.deployment.gettingDeploys = false;
@@ -80,19 +87,16 @@ export const deployClicked: AsyncAction = async ({
8087
effects,
8188
actions,
8289
}) => {
83-
state.deployment.deploying = true;
84-
const zip = await effects.zip.create(state.editor.currentSandbox);
85-
const contents = await effects.jsZip.loadAsync(zip.file);
86-
8790
try {
91+
state.deployment.deploying = true;
92+
const zip = await effects.zip.create(state.editor.currentSandbox);
93+
const contents = await effects.jsZip.loadAsync(zip.file);
8894
state.deployment.url = await effects.zeit.deploy(
8995
contents,
9096
state.editor.currentSandbox
9197
);
9298
} catch (error) {
93-
effects.notificationToast.error(
94-
'An unknown error occurred when connecting to ZEIT'
95-
);
99+
effects.notificationToast.error(getZeitErrorMessage(error));
96100
}
97101

98102
state.deployment.deploying = false;

0 commit comments

Comments
 (0)