Catching exceptions for the unfinished getVal function