Skip to content

Commit 44e681b

Browse files
committed
Improved error message
1 parent a12524e commit 44e681b

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 with 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 with 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy