Skip to content

Conversation

@dantleech
Copy link
Contributor

@dantleech dantleech commented Apr 27, 2016

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no/yes ?
Deprecations? no
Tests pass? ?
Fixed tickets
License MIT
Doc PR

Current when this mapping pass cannot find (any of) the configured managers the user receives the following exception:

[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]                                                                              
You have requested a non-existent parameter "Could not determine the Doctrine manager. Either Doctrine is not configured or a bundle is misconfigured.". 

Which is misleading and strange.

This PR changes the exception to an InvalidArgumentException and provides the following message:

[InvalidArgumentException]                                                                                                                     
Could not find the object manager name parameter. Tried: "cmf_routing.dynamic.persistence.orm.manager_name", "doctrine.default_entity_manager"  

@dantleech dantleech force-pushed the better_exceptoin_mapping_pass branch from e1591da to 07c46b0 Compare April 27, 2016 11:06
@dantleech dantleech changed the title Use better exception in the register mapping pass [Bridge/Doctrine] Use better exception in the register mapping pass Apr 27, 2016
@dantleech dantleech force-pushed the better_exceptoin_mapping_pass branch from 07c46b0 to a513f47 Compare April 27, 2016 11:22
- When no manager name parameter found, throw a more informative exception.
@dantleech dantleech force-pushed the better_exceptoin_mapping_pass branch from a513f47 to 0eeedee Compare April 27, 2016 11:23
}

throw new ParameterNotFoundException('Could not determine the Doctrine manager. Either Doctrine is not configured or a bundle is misconfigured.');
throw new \InvalidArgumentException(sprintf(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is potentially a BC break if anybody was depending on the ParameterNotFoundException for any reason.
  2. Should this be a DependencyInjection\Exception\InvalidArgumentException or similar?

@nicolas-grekas
Copy link
Member

@dantleech we prefer doing this kind of changes on master because of the potential BC break you spotted...

@dantleech dantleech closed this Apr 27, 2016
@dantleech dantleech reopened this Apr 27, 2016
@dantleech
Copy link
Contributor Author

Looks like I already based it on master by accident.

@javiereguiluz javiereguiluz added DX DX = Developer eXperience (anything that improves the experience of using Symfony) DoctrineBridge labels Apr 27, 2016
@fabpot
Copy link
Member

fabpot commented May 13, 2016

Thank you @dantleech.

@fabpot fabpot merged commit 0eeedee into symfony:master May 13, 2016
fabpot added a commit that referenced this pull request May 13, 2016
… mapping pass (dantleech)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[Bridge/Doctrine] Use better exception in the register mapping pass

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no/yes ?
| Deprecations? | no
| Tests pass?   | ?
| Fixed tickets |
| License       | MIT
| Doc PR        |

Current when this mapping pass cannot find (any of) the configured managers the user receives the following exception:

```
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "Could not determine the Doctrine manager. Either Doctrine is not configured or a bundle is misconfigured.".
```

Which is misleading and strange.

This PR changes the exception to an `InvalidArgumentException` and provides the following message:

```
[InvalidArgumentException]
Could not find the object manager name parameter. Tried: "cmf_routing.dynamic.persistence.orm.manager_name", "doctrine.default_entity_manager"
```

Commits
-------

0eeedee Use better exception in the register mapping pass
@fabpot fabpot mentioned this pull request May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DoctrineBridge DX DX = Developer eXperience (anything that improves the experience of using Symfony) Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants