Restore context on error.