INF310: Modern JS, Fall 2017 > Language Features > Error handling
Error handling
try/catch
  try {
    null.doSomething();
  } catch (error) {
    console.log('null can\'t do shit');
  }
throw
  function sum(a, b) {
    if (!a || !b) {
      throw new Error('expected 2 arguments');
    }
  }

  sum(1); // throws an error