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
client.getAttribute(mbean, attrib, data => {
...do something with the data..
});
The way the api is designed there seems to be no way to change this code so that it can properly handle errors arising from that operation.
Yes, we can do something like this:
client.on('error', (error) => ...handle error..);
But... the error handler can not know what operation caused the error. Even if we use client.on in combination with client.of to only attach error handlers for the duration of an operation, we will still have issues to accurately determine which operation caused the error when more than one operation is executed in parallel.
So, to make story short, the api should really allow for something like this:
client.getAttribute(mbean, attrib, (data, err) => {
if (error) {
..handle error...
} else {
..do something with the data..
}
});
Note: if the api was designed like this from the start, I would probably put the 'err' parameter before the 'data' parameter as that seems to be the prevailing convention for asynchronous callbacks in nodejs libraries.
But seeing as the api was not designed to work like this initially, putting the 'err' parameter second means that it will not break existing code that assumes the first parameter is the data.
The text was updated successfully, but these errors were encountered:
Let's say we have code like this:
The way the api is designed there seems to be no way to change this code so that it can properly handle errors arising from that operation.
Yes, we can do something like this:
But... the error handler can not know what operation caused the error. Even if we use
client.on
in combination with client.of to only attach error handlers for the duration of an operation, we will still have issues to accurately determine which operation caused the error when more than one operation is executed in parallel.So, to make story short, the api should really allow for something like this:
Note: if the api was designed like this from the start, I would probably put the 'err' parameter before the 'data' parameter as that seems to be the prevailing convention for asynchronous callbacks in nodejs libraries.
But seeing as the api was not designed to work like this initially, putting the 'err' parameter second means that it will not break existing code that assumes the first parameter is the data.
The text was updated successfully, but these errors were encountered: