yocontra / node-gdal-next

Node.js bindings for GDAL (Geospatial Data Abstraction Library) [Fork]
https://contra.io/node-gdal-next/
Apache License 2.0
75 stars 35 forks source link

Raster async functions throw synchronously when the arguments are invalid #37

Closed mmomtchev closed 3 years ago

mmomtchev commented 3 years ago

If an error is detected during the parsing of the arguments phase (the synchronous phase), the raster async functions with throw a synchronous error when called with a callback (as opposed to Promise). I/O errors are reported via the callback and the Promisified-versions work as they should - by rejecting the Promise whether the error is during the synchronous or the asynchronous phase.

The callback versions should report errors only through the callback as it is the norm in all standard Node.js libraries

mmomtchev commented 3 years ago

In fact, some standard libraries do exhibit the same behaviour... ok, maybe this will stay like this for the time being

yocontra commented 3 years ago

I think this behavior is valid - if the error is with arguments and not execution of work it should be thrown in the main thread, since it is the main threads problem for invoking with invalid arguments.