Fixed wrong exception if cache directory is not writable.