fix: add a little error checking to settings (#315)
* fix: add a little error checking to settings * fix: add a little more
This commit is contained in:
@@ -101,8 +101,12 @@ export default function Settings(): JSX.Element {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchGitHubStats = async () => {
|
const fetchGitHubStats = async () => {
|
||||||
|
try {
|
||||||
const stats = await gitHubStatsService.fetchGitHubStats();
|
const stats = await gitHubStatsService.fetchGitHubStats();
|
||||||
setGitHubStats(stats);
|
setGitHubStats(stats);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Error fetching GitHub stats:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const initAndSetSettings = async () => {
|
const initAndSetSettings = async () => {
|
||||||
@@ -207,7 +211,14 @@ export default function Settings(): JSX.Element {
|
|||||||
// Exit if the user cancels the prompt
|
// Exit if the user cancels the prompt
|
||||||
if (link === null) return;
|
if (link === null) return;
|
||||||
|
|
||||||
const response = await fetch(link);
|
try {
|
||||||
|
let response: Response;
|
||||||
|
try {
|
||||||
|
response = await fetch(link);
|
||||||
|
} catch (e) {
|
||||||
|
alert(`Failed to fetch url '${link}'`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
const doc = new DOMParser().parseFromString(text, 'text/html');
|
const doc = new DOMParser().parseFromString(text, 'text/html');
|
||||||
|
|
||||||
@@ -231,6 +242,9 @@ export default function Settings(): JSX.Element {
|
|||||||
} else {
|
} else {
|
||||||
console.log(courses);
|
console.log(courses);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error scraping course:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [devMode, toggleDevMode] = useDevMode(10);
|
const [devMode, toggleDevMode] = useDevMode(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user