You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read/Write Tags/Groups should be more await friendly by allowing const [ error, data ] = PLC.readTag( tag )
Current Behavior
You can currently await any of these functions but if an error happens, it throws an uncaught promise error which are pretty annoying to track down. The workaround is to write a wrapper for each function that returns a promise and catch errors yourself which makes the current level of support for await pointless.
Expected Behavior
You should be able to handle all errors like so:
const[error,data]=PLC.readTag(tag)if(error){// handle the error, log error, break you current block, etc}
Another option could be to pass an error callback but... or an options object to control return structure
Possible Solution (Optional)
Each of these functions should contain a then and a catch and both should return something and not cause unhandled promise rejection errors. Returning [ false, data ] could be a breaking change however so a callback could be added to be executed on the catch block.
I currently use await-to-js to "awaitify" these functions.
Context
Trying to use async await much more than I used to and encountering unexpected issues or forgetting to use helper functions.
Steps to Reproduce (for bugs only)
Use any await example from the README
Try it on a tag that doesn't exist or throws some other error
Program dies
Your Environment
Package version (Use npm list - e.g. 1.0.6):
Node Version (Use node --version - e.g. 9.8.0):
Operating System and version:
Controller Type (eg 1756-L83E/B):
Controller Firmware (eg 30.11):
The text was updated successfully, but these errors were encountered:
Read/Write Tags/Groups should be more await friendly by allowing
const [ error, data ] = PLC.readTag( tag )
Current Behavior
You can currently await any of these functions but if an error happens, it throws an uncaught promise error which are pretty annoying to track down. The workaround is to write a wrapper for each function that returns a promise and catch errors yourself which makes the current level of support for await pointless.
Expected Behavior
You should be able to handle all errors like so:
Another option could be to pass an error callback but... or an options object to control return structure
Possible Solution (Optional)
Each of these functions should contain a
then
and acatch
and both should return something and not cause unhandled promise rejection errors. Returning[ false, data ]
could be a breaking change however so a callback could be added to be executed on thecatch
block.I currently use await-to-js to "awaitify" these functions.
Context
Trying to use async await much more than I used to and encountering unexpected issues or forgetting to use helper functions.
Steps to Reproduce (for bugs only)
Your Environment
npm list
- e.g. 1.0.6):node --version
- e.g. 9.8.0):The text was updated successfully, but these errors were encountered: