Skip to content

Commit

Permalink
Warn instead of throwing an error
Browse files Browse the repository at this point in the history
And after the warning, return. This prevents Node-RED from crashing.
  • Loading branch information
dirkjanfaber committed Nov 8, 2024
1 parent 1ce472e commit 855224d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/nodes/victron-virtual.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
RED.nodes.registerType('victron-virtual',{
category: 'Victron Energy',
color: '#f7ab3e',
paletteLabel: "Virtual Device",
defaults: {
name: {value:""},
device: {value:"", required: true},
Expand Down
20 changes: 18 additions & 2 deletions src/nodes/victron-virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,27 @@ module.exports = function (RED) {
: dbus.systemBus()
}
if (!this.bus) {
throw new Error('Could not connect to the DBus session bus.')
node.warn(
'Could not connect to the DBus session bus.'
)
node.status({
color: 'red',
shape: 'dot',
text: 'Could not connect to the DBus session bus.'
})
return
}

if (!config.device || config.device === '') {
throw new Error('Node needs a configuration first')
node.warn(
'No device configured'
)
node.status({
color: 'red',
shape: 'dot',
text: 'No device configured'
})
return
}

let serviceName = `com.victronenergy.${config.device}.virtual_${this.id}`
Expand Down

0 comments on commit 855224d

Please sign in to comment.