Skip to content

"Catch" doesn't catch all exceptions #9

@christofkac

Description

@christofkac

I'm using your library successfully, really thanks for the work.
I use it in an ioBroker (homeautomation server) environment which is JavaScript based.

My problem is, that from time to time I get an uncaugt exception which crashes the JavaScript engine in ioBroker.
I based my code on your example:

function ReadValues()
{
// Instantiate client
const client = NefitEasyClient({
serialNumber : "xx",
accessKey : "yy",
password : "zz",
});
// Connect client and retrieve status and pressure.
client.connect().then( () =>
{
return Promise.all([ client.status(), client.pressure() ]);
}).then(response =>
{
const status = response[0];
console.log(JSON.stringify(status));
const pressure = response[1];
console.log("Temperature is set to " + status['temp setpoint'].toFixed(1) + " °C, current is " + status['in house temp'].toFixed(1) + " °C.\n" +
"Outside temperature is "+status['outdoor temp'].toFixed(1)+" °C.\n" +
"User Mode is "+status['user mode']+".\n" +
"System pressure is " + pressure.pressure + " " + pressure.unit);
}).catch((e) =>
{
console.error(e);
}).finally(() =>
{
client.end();
});
}

My output:

2020-01-02 09:12:01.314 - info: javascript.0 (28942) script.js.common.Nefit: {"user mode":"clock","clock program":"auto","in house status":"ok","in house temp":19.6,"hot water active":true,"boiler indicator":"central heating","control":"room","temp override duration":0,"current switchpoint":24,"ps active":false,"powersave mode":false,"fp active":false,"fireplace mode":false,"temp override":false,"holiday mode":false,"boiler block":null,"boiler lock":null,"boiler maintenance":null,"temp setpoint":21,"temp override temp setpoint":17,"temp manual setpoint":21,"hed enabled":null,"hed device at home":null,"outdoor temp":3,"outdoor source type":"virtual"}
2020-01-02 09:12:01.314 - info: javascript.0 (28942) script.js.common.Nefit: Temperature is set to 21.0 °C, current is 19.6 °C.
Outside temperature is 3.0 °C.
User Mode is clock.
System pressure is 1.8 bar
2020-01-02 09:12:01.342 - error: javascript.0 (28942) uncaught exception: read ECONNRESET
2020-01-02 09:12:01.343 - error: javascript.0 (28942) Error: read ECONNRESET
2020-01-02 09:12:01.963 - error: host.ioBroker Caught by controller[0]: { Error: read ECONNRESET
--
2020-01-02 09:12:01.964 - error: host.ioBroker Caught by controller[0]: at TLSWrap.onread (net.js:622:25)
2020-01-02 09:12:01.964 - error: host.ioBroker Caught by controller[0]: errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }

So although the readout was successful, the exception ECONNRESET is thrown and unfortunately not caught be the "catch" statement.

Any hint?
Thanks
Christof

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions