Skip to content

Commit

Permalink
fix(#1401): Handle error when loading gist
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Apr 5, 2024
1 parent 44eeceb commit 57eef9d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/util/fileLoaders/gist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { addHistoryEntry } from '$lib/components/History/history';
import type { State } from '$lib/types';
import { defaultState } from '$lib/util/state';
import { addHistoryEntry } from '$lib/components/History/history';
import { fetchJSON, fetchText } from '$lib/util/util';

const codeFileName = 'code.mmd';
Expand Down Expand Up @@ -102,8 +102,12 @@ export const loadGistData = async (gistURL: string): Promise<State> => {
);
const gistHistory: GistData[] = [];
for (const entry of history) {
const data: GistData | undefined = await getGistData(entry.url).catch();
data && gistHistory.push(data);
try {
const data: GistData = await getGistData(entry.url);
gistHistory.push(data);
} catch (error) {
console.error(error);
}
}
if (gistHistory.length === 0) {
throw new Error('Invalid gist provided');
Expand Down

0 comments on commit 57eef9d

Please sign in to comment.