I am making a simple UDP “send” using Node's built-in UDP socket datagram:
http://nodejs.org/docs/v0.3.1/api/dgram.html
The purpose of the message is the domain name that must be resolved by DNS before the transfer .. node.js handles this.
If the DNS resolution fails, dgram generates an "ENOTFOUND Domain Not Found" error and passes it to the callback that I registered.
My code looks like this:
client = dgram.createSocket("udp4");
client.send(message,
0,
message.length,
this.port,
this.address,
function(err, bytes) {
if (err) {
}
}
);
client.close();
I'm not particularly interested in the error. If it fails, it fails, which is not important for the business rules of the application. I will write it to the console for completeness. BUT I cannot stop this exception by going back to the stack and knocking the application down. How can I handle this error?
, . Try/Except.. .
?
.