fix lint rules and small readme improve

This commit is contained in:
2023-12-06 21:05:52 +01:00
parent fa1bb19623
commit 2f35776696
12 changed files with 73 additions and 63 deletions

View File

@@ -47,9 +47,13 @@ function processFile(filePath: string): number | null {
const lines = data.trim().split('\n');
const cards = lines.map(parseCardData);
return processCards(cards);
} catch (error: any) {
console.error(`Error processing file ${filePath}: ${error.message}`);
return null;
} catch (error) {
if (error instanceof Error) {
console.error(`Error processing file ${filePath}: ${error.message}`);
return null;
} else {
console.error(`An unknown error occurred`);
}
}
}
@@ -67,8 +71,12 @@ function main() {
test();
const totalCards = processFile('../input.txt');
console.log(`Total cards from input.txt: ${totalCards}`);
} catch (error: any) {
console.error(`An error occurred: ${error.message}`);
} catch (error) {
if (error instanceof Error) {
console.error(`An error occurred: ${error.message}`);
} else {
console.error(`An unknown error occurred`);
}
}
}