Output value was being persisted through the exception

Fix #4098