Move undodir/undofile settings into try..catch block