1+ import { AxiosError } from 'axios' ;
2+ import { get } from 'lodash-es' ;
13import { Action , AsyncAction } from 'app/overmind' ;
24import * as internalActions from './internalActions' ;
35
46export 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+
615export 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