Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug #22976 [DependencyInjection] Use more clear message when unused e…
…nvironment variables detected (voronkovich)

This PR was squashed before being merged into the 3.2 branch (closes #22976).

Discussion
----------

[DependencyInjection] Use more clear message when unused environment variables detected

| Q             | A
| ------------- | ---
| Branch?       |3.2
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22955
| License       | MIT

Old error message:
```
Incompatible use of dynamic environment variables "DATABASE_URL", "MAILER_URL" found in parameters.
```

New error message:
```
Environment variables "DATABASE_URL", "MAILER_URL" are never used. Please, check your container's configuration.
```

Commits
-------

6dbdb1b [DependencyInjection] Use more clear message when unused environment variables detected
  • Loading branch information
fabpot committed Jun 3, 2017
2 parents 7078cdf + 6dbdb1b commit 12f5636
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Expand Up @@ -166,7 +166,7 @@ public function dump(array $options = array())
}
}
if ($unusedEnvs) {
throw new EnvParameterException($unusedEnvs);
throw new EnvParameterException($unusedEnvs, null, 'Environment variables "%s" are never used. Please, check your container\'s configuration.');
}

return $code;
Expand Down
Expand Up @@ -18,8 +18,8 @@
*/
class EnvParameterException extends InvalidArgumentException
{
public function __construct(array $usedEnvs, \Exception $previous = null)
public function __construct(array $envs, \Exception $previous = null, $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.')
{
parent::__construct(sprintf('Incompatible use of dynamic environment variables "%s" found in parameters.', implode('", "', $usedEnvs)), 0, $previous);
parent::__construct(sprintf($message, implode('", "', $envs)), 0, $previous);
}
}
Expand Up @@ -302,7 +302,7 @@ public function testEnvParameter()

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\EnvParameterException
* @expectedExceptionMessage Incompatible use of dynamic environment variables "FOO" found in parameters.
* @expectedExceptionMessage Environment variables "FOO" are never used. Please, check your container's configuration.
*/
public function testUnusedEnvParameter()
{
Expand Down

0 comments on commit 12f5636

Please sign in to comment.