In Google Apps Script how do I check if a reference is out of range?

I have some Google Apps Script code which works with Google Sheets. In one segment of code there are some instances where it throws an exception.

Here is the exception:

Exception: Cell reference out of range

Here is the line of code (and the one preceding it) that is throwing the exception:

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Reservations');
  var cell = sheet.getActiveCell(); // This is where the exception is thrown

This error happens but not consistently. What I want to do is check if sheet.getActiveCell() is pointing to a reference out of range or if it is returning a valid value. If it is pointing to a reference that is out of range I would like to set the value of cell to an alternative value.

How do I check if sheet.getActiveCell() is returning a value that is in range?