I’m coming pack to Node, trying to use it for some file parsing functionality, but I’m encountering some absolutely bewildering behavior.
I have this parser class that is supposed to open a file then parse it line by line. When I pass it a file path that doesn’t exist, it doesn’t throw an Error but it also doesn’t continue executing. I’ve tried debugging it and the debugger just detaches when I try to continue to a breakpoint I’ve set inside of the catch block. But I also know the open
promise isn’t being fulfilled because it should be at least continuing on to the parseLines
method call where it is supposed to simply print ‘Parsing lines’ to the terminal, but it’s not.
I have to be missing something very fundamental.
async parse(filePath: string) {
try {
this._file = await open(filePath, 'r');
}
catch (ex) {
console.log(ex);
}
this.parseLines();
}
private parseLines() {
console.log('Parsing lines');
1