Added exception handling to setValue.