I currently have a try/finally block of this format:
try {
var someOtherObject = new SomeOtherObject(param1, param2);
someOtherObject.doStuff();
// Object that basically holds a 'result set' of csv rows.
var csv = new CsvObject();
csv.openCSV(); // does not throw an error
do {
try {
// Code that grabs stuff from the csv in a straightforward fashion.
} catch (e) {
log.info(e); // Log the error and continue on.
}
} while (csv.hasNext());
} finally {
csv.closeFileCSV(); //throws a TypeError: Cannot call closeFileCSV() on undefined.
}
No errors are thrown in the loop, nor anywhere else that I can tell outside the finally block. Can anyone give me clues as to why it would throw a TypeError when calling closeFileCSV in the finally block? I'm not a javascript expert but it doesn't seem like scope should be a problem here. I know that csv gets initialized correctly, because the try block uses the object to do stuff and no errors are thrown.
I'm hoping I'm just not seeing something obvious. Let me know if more code needs to be pasted in order to solve this.
Thanks.