Took care of sys.last_value only being defined after at least one error occurred. Premature usage caused an AttributeError.