Fixed exception handling in getAsString()