Skip to content

Commit

Permalink
propagate error on correct level
Browse files Browse the repository at this point in the history
  • Loading branch information
foxriver76 committed Aug 25, 2024
1 parent 2c17dd1 commit 9c440e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/visuApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* Handles `sendToAdapter` command
* @param {SendToAdapterCommand} visuData the data sent by the app
* @param {ioBroker.Adapter} adapter the adapter instance
* @returns {Promise<{ message: ioBroker.Message }>}
* @returns {Promise<Record<string, any>>}
*/
async function handleSendToAdapter(visuData, adapter) {
const { instance, message, data } = visuData;

const resp = await adapter.sendToAsync(instance, message, data,{ timeout: 20_000 });
return { message: resp };
return { ...resp };
}

/** @typedef {{ command: 'getInstances', adapterName: string }} GetInstancesCommand */
Expand Down
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,12 @@ async function processMessage(type, request) {

if (visuData.command === 'sendToAdapter') {
const res = await handleSendToAdapter(visuData, adapter);
return { result: 'Ok', ...res }

if (!res.error) {
res.result = 'Ok';
}

return res;
}
} catch (e) {
adapter.log.error(`Could not handle data "${request}" by Visu App: ${e.message}`)
Expand Down

0 comments on commit 9c440e0

Please sign in to comment.