From e01b302f3de0f2e33a09f2426be3c3f0671410cd Mon Sep 17 00:00:00 2001 From: Patrick Joyce Date: Mon, 19 Feb 2024 12:08:27 -0500 Subject: [PATCH] update type, reject instead of throw err --- src/lib/DataUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/DataUtils.ts b/src/lib/DataUtils.ts index 816f1f2..8bcc23e 100644 --- a/src/lib/DataUtils.ts +++ b/src/lib/DataUtils.ts @@ -21,7 +21,7 @@ interface Meeting { export async function fetchData(query: string): Promise { try { if (!query.includes('/client_interface/json')) { - throw new Error('Query does not contain a valid json endpoint.'); + return Promise.reject(new Error('Query does not contain a valid json endpoint.')); } const updatedQuery = query.replace('/client_interface/json/', '/client_interface/jsonp/'); const response = await fetchJsonp(updatedQuery, { @@ -30,7 +30,7 @@ export async function fetchData(query: string): Promise { }); const data = await response.json(); if (!Array.isArray(data) || data.length === 0) { - throw new Error('No data found'); + return Promise.reject(new Error('No data found')); } return data; } catch (error) { @@ -110,7 +110,7 @@ function createPlacemark(meeting: Meeting): string { `.trim(); } -function prepareSimpleLine(meeting: Meeting, withDate = true): string { +function prepareSimpleLine(meeting: Meeting, withDate: boolean = true): string { const getLocationInfo = () => { const locationInfo: string[] = []; const addInfo = (property: keyof Meeting) => {