Skip to content

error callback is undefined #1314

Description

@dennisdupont

Using v1.7.2 in a node app.

Was testing a select from a non-existing JSON file (shamelessly stolen from the multiple JSON file wiki example).
alasql(['SELECT * FROM JSON("a.json")']) .then(function(res) { var a = res[0]; }).catch(function(err) { console.log(error: ${err}); }) ;

Expected behavior is to catch the error. Instead I get a process-ending unhandled exception.

FYI: Different cause, but another unhandled exception occurs on a JSON.parse error, although one could argue that if the file exists it ought to expected to contain valid JSON. Still, a try catch is in order when parsing IMO.

jsfiddle was not working for node so I created a similar version at runkit:
https://runkit.com/60677da356be380013a31abc/60677da318e85d001c2257fc

Looking at the code for loadFile, the last parameter is an error callback. However, it does not seem that the JSON from function (nor the other text from functions) pass in that error handler.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions