diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl
index 0cd0612dd09592746911edc33d89a5764ebd5417..05238e08dfc362e2e1f8bde0d27476427ef15775 100644
--- a/bin/slubsipbuilderbagit.pl
+++ b/bin/slubsipbuilderbagit.pl
@@ -435,7 +435,11 @@ PATCH
         my $path = $_[0];
 
         if(! -d $path && ! -f $path){
-            mkdir($path) or die "Could not mkdir $path: $!";
+            eval { path($path)->mkpath; };
+            if ($@) { # error
+                print_scalar_data("", "ERROR: Failed to create directory '$path'.", "", "red");
+                die $@;
+            }
         }
         return 1;
     }