Skip to content

Commit 5623b5a

Browse files
committed
Update app.ts
1 parent fbaf2af commit 5623b5a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

website/workers/app.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff 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" ||

0 commit comments

Comments
 (0)