Skip to content

Instantly share code, notes, and snippets.

Node Error Handling and Domains

"Occurrences in this domain are beyond the reach of exact prediction because of the variety of factors in operation, not because of any lack of order in nature." - Albert Einstein

"Master of my domain" - Larry David

Error handling in an asynchronous language works in a unique way and presents many challenges, some unexpected. This tutorial reviews the various error handling patterns available in node, and explains how domains can be used to improve it.

There are four main error handling patterns in node:

  • Error return value
#!/usr/bin/env bash
# gsettings list-recursively org.gnome.system.proxy
# Change de ip address and port number accordingly.
function myProxyOn() {
gsettings set org.gnome.system.proxy mode 'manual' # ' manual / nome / automatic '
gsettings set org.gnome.system.proxy.http host '10.0.0.1'
gsettings set org.gnome.system.proxy.http port 8080
gsettings set org.gnome.system.proxy.https host '10.0.0.1'