Is There a "Predefined Exception" for Handling ArrayOutOfBounds Indexing Errors in PHP?

one text

Solution:

I'm not sure if there's a better way to do this, but here is a manual solution. The error is not automatically generated such as in the divideByZero() function, so I threw an error manually.

function arrayOutOfBounds() {
  $arr = ["", "", ""];
  if (isset($arr[3])) {} else {
    throw new OutOfBoundsException("Index was outside the bounds of the array.");
  }
};

try {
  arrayOutOfBounds();
  echo "test"; //i dont run anymore
} catch (OutOfBoundsException $err) {
  echo $err; //i echo the $err message
};

Source