From c6a6f1167057fb157093cd414eaf498e9a67040f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Mon, 26 Mar 2018 11:28:24 +0200 Subject: [PATCH 1/1] Catch directory creation failure with a nice message --- Twig/PackTokenParser.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Twig/PackTokenParser.php b/Twig/PackTokenParser.php index 2644a1b..64de8e5 100644 --- a/Twig/PackTokenParser.php +++ b/Twig/PackTokenParser.php @@ -216,7 +216,11 @@ class PackTokenParser extends \Twig_TokenParser { //Create output dir on demand if (!is_dir($parent = $dir = dirname($this->prefix.$output))) { //XXX: set as 0777, symfony umask (0022) will reduce rights (0755) - mkdir($dir, 0777, true); + try { + mkdir($dir, 0777, true); + } catch (\Exception $e) { + throw new \Twig_Error_Syntax(sprintf('Unable to create directory: %s', $dir), $token->getLine(), $stream->getSourceContext()); + } } //Send file content -- 2.41.1