Armin Mesicpersonal blog

If a switch statement doesn’t have a default case you can throw an error if the input is invalid

switch (someVal) {
  case 1:
    // do something
    break;
  case 2:
    // do something
    break;
  default:
    throw new someException('some message')
    break;
}