try { //something that causes an error } catch (ex){ if (ex instanceof TypeError){ //handle the error } else if (ex instanceof ReferenceError){ //handle the error } else { //handle all others } }