added try catch to haifa

This commit is contained in:
Kfir Dayan 2024-02-04 12:54:32 +02:00
parent dbdf76554b
commit 265a182d8f

View file

@ -10,7 +10,10 @@ import moment from "moment"; // require
export default class GameSource {
async getGamesFromHaifa(): Promise<GoogleCalendarEvent[]> {
const sourceUrl = `http://mhaifafc.com/games?lang=en`;
console.log('Trying to get games from Haifa...');
try {
const result = await axios.get(sourceUrl);
const parsedResult = parse(result.data.toString());
const gameBoxs = parsedResult.querySelectorAll(".game-box");
@ -62,6 +65,10 @@ export default class GameSource {
// return [];
return games;
}
catch (error) {
console.error(error);
}
}
private findTime(headerSplit: string[]) {
let time = '';