Closed bl0ggy closed 4 years ago
Hi The try/catch is fine. In another part of the project (in some of the Pull event handler code) I import the lodash-get library (a small part of lodash). This has a _get fuction which does not throw if you get an item that is null (or the parent is null)
You can see me using it here... https://github.com/agsh/onvif/commit/ccdaff3a09b0232ebc4e9841ec74e8bdef5c2554
So I'll do the commit because try/catch is fine. But _get may give cleaner looking code in the future.
Thanks Roger
I did not know about that library, thank you for the information.
There are a few NodeJS libraries that are very popular and used in lots of software. One is called Underscore and the other is called Lodash.
They are libraries packed will handy functions to make writing javascript easier.
Roger
On SOAP error, some cameras send a wrong SOAP structure (see Issue #73). This PR permit to avoid having the error
"TypeError: Cannot read property '0' of undefined"
, but instead will try to read bothreason
anddetail
information, if one of them is wrong, we can still get the other.