Skip to content

Error handling on readFile #321

@simonh1000

Description

@simonh1000

I am trying to automate an xls file download and import in Mongo process. Every so often I think my file download is not working properly and I get erorrs from Xlsx [TypeError: Cannot read property '3' of undefined], but I am unable to find a way to catch these errors with code - can you advise?

function xls2Json(fname) {
    return new Promise( (resolve, reject) => {
        var wbook = XLSX.readFile(fname+'.xls');
        var worksheet = wbook.Sheets[SHEET_NAME];
        let json = XLSX.utils.sheet_to_json(worksheet, {header:headers, range:1});
        resolve(json);
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions