File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed
Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,11 @@ export class HandleReceivedObservation extends WorkflowEntrypoint<
135135 {
136136 method : "GET" ,
137137 }
138- ) . then ( ( response ) => response . text ( ) ) ;
138+ ) . then ( ( response ) => {
139+ if ( ! response . ok )
140+ throw new Error ( "Windguru failed, status: " + response . status ) ;
141+ return response . text ( ) ;
142+ } ) ;
139143 if ( response !== "OK" ) {
140144 throw new Error ( `Windguru upload failed: ${ response } ` ) ;
141145 }
@@ -178,13 +182,14 @@ export class HandleReceivedObservation extends WorkflowEntrypoint<
178182 {
179183 method : "GET" ,
180184 }
181- ) . then ( ( response ) => response . json ( ) ) ;
182- if (
183- ! response ||
184- typeof response !== "object" ||
185- Object . keys ( response ) . length !== 0
186- )
185+ ) . then ( ( response ) => {
186+ if ( ! response . ok )
187+ throw new Error ( "Windy upload failed, status: " + response . status ) ;
188+ return response . json ( ) ;
189+ } ) ;
190+ if ( ! response || typeof response !== "object" )
187191 throw new Error ( `Windy upload failed: ${ JSON . stringify ( response ) } ` ) ;
192+ return JSON . stringify ( response ) ;
188193 }
189194 ) ;
190195 await step . do (
@@ -231,7 +236,13 @@ export class HandleReceivedObservation extends WorkflowEntrypoint<
231236 {
232237 method : "GET" ,
233238 }
234- ) . then ( ( response ) => response . json ( ) ) ;
239+ ) . then ( ( response ) => {
240+ if ( ! response . ok )
241+ throw new Error (
242+ "Met Office upload failed, status: " + response . status
243+ ) ;
244+ return response . json ( ) ;
245+ } ) ;
235246 if (
236247 ! response ||
237248 typeof response !== "object" ||
You can’t perform that action at this time.
0 commit comments