Try to create the cache directory before throwing an exception

I think it is less restrictive if the module try to create the cache directory before throwing an exception.