Skip to content

Commit 304f52a

Browse files
committed
Improved error message
1 parent a12524e commit 304f52a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/Dotenv/Dotenv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ private function resolveVariables($value)
459459

460460
if ('' === $value && isset($matches['default_value'])) {
461461
if ('{' !== $matches['opening_brace']) {
462-
throw $this->createFormatException(sprintf('Missing braces on variable expansion with default value "%s"', $matches['default_value']));
462+
throw $this->createFormatException(sprintf('Variable expansion "$%s%s" should be wrapped in braces', $name, $matches['default_value']));
463463
}
464464

465465
$unsupportedChars = strpbrk($matches['default_value'], '\'"{$');

src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getEnvDataWithFormatErrors()
5151
["FOO=\nBAR=\${FOO:-\'a{a}a}", "Unsupported character \"'\" found in the default value of variable \"\$FOO\". in \".env\" at line 2.\n...\\nBAR=\${FOO:-\'a{a}a}...\n ^ line 2 offset 24"],
5252
["FOO=\nBAR=\${FOO:-a\$a}", "Unsupported character \"\$\" found in the default value of variable \"\$FOO\". in \".env\" at line 2.\n...FOO=\\nBAR=\${FOO:-a\$a}...\n ^ line 2 offset 20"],
5353
["FOO=\nBAR=\${FOO:-a\"a}", "Unclosed braces on variable expansion in \".env\" at line 2.\n...FOO=\\nBAR=\${FOO:-a\"a}...\n ^ line 2 offset 17"],
54-
["FOO=\nBAR=\$FOO:-a", "Missing braces on variable expansion with default value \":-a\" in \".env\" at line 2.\n...FOO=\\nBAR=\$FOO:-a...\n ^ line 2 offset 16"],
54+
["FOO=\nBAR=\$FOO:-a", "Variable expansion \"\$FOO:-a\" should be wrapped in braces in \".env\" at line 2.\n...FOO=\\nBAR=\$FOO:-a...\n ^ line 2 offset 16"],
5555
];
5656

5757
if ('\\' !== \DIRECTORY_SEPARATOR) {

0 commit comments

Comments
 (0)