CORE if directory cannot be created, throw exception

(cherry picked from commit c7d657596c7d0ea5f8428da9782fd50ad3ef87f2)