Empty Array as Error Value when using `invoke`
athanclark opened this issue · comments
I don't have a reproducible example at this moment, but what would cause this value to be an array, or an empty one?
bus.invoke({
// ... args
}, function (e, result) {
// usually e is either `null` or some error, in my case it's the empty array `[]`
});
However, to be clear, result === undefined
when e === []
as well, so there must be an error going on under the hood.
code that calls your callback is here: https://github.com/sidorares/node-dbus/blob/d9a8176dea9d02c50b75a46c0cee8bf45e92da86/lib/bus.js#L109
can you dump what's in the message? Depending on message type
, the callback is supposed to be called as (null, ...message.body)
if it's method return and (...messageBody)
if it's 'error'
I guess correct way would be do do something like this for error:
const err = new Error();
err.messageBody = msg.body;
handler(err);
Do you mean the return message? This is what I received:
{ serial: 3,
signature: '',
errorName: 'org.freedesktop.DBus.Error.InvalidParameters',
replySerial: 2,
destination: ':1.309',
sender: ':1.311',
type: 3,
flags: 0 }
The weird part is I know for sure that the method I'm calling has a String -> String
type signature - I can see it with d-feet. I'm trying to find the line where I can inject some logging for the messages I'm sending, if you can point me in the direction :x
Actually what you get is kind of expected, it's just error message body is empty
Probably more important for your logic is error name returned:
bus.invoke({
// ... args
}, function (e, result) {
if (e !== null) {
console.log(this.message.errorName)
}
});
I'll keep this issue open to track api change: in case of error instance of Error()
will be returned with message set to msg.errorName
yeah I think you're right, this makes a ton of sense. I'll close this now that we know where the issue is. Thank you for your help!!