change merge validate errors to MergeError from ValueError
State: closed

Final changes from #16275 that failed to push before merge. Converts errors from `validate` argument of `merge` command to `MergeError`s from `ValueError`s. 


Labels:
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
@nickeubank would you mind moving the `MergeError` definition to `pandas/errors/__init__.py` (and adding a docstring), then importing it where needed. A bit more consistent (though I know you didn't add it).
You might have to update the tests in `pandas/tests/api/test_api.py` FYI
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=h1) Report
> Merging [#16436](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/49ec31bbaeca81a6f58fc1be26fe80f3ac188cdd?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16436/graphs/tree.svg?token=eZ4WkYLtcO&src=pr&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #16436   +/-   ##
=======================================
  Coverage   90.42%   90.42%           
=======================================
  Files         161      161           
  Lines       51023    51023           
=======================================
  Hits        46138    46138           
  Misses       4885     4885
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <100%> (ø)` | :arrow_up: |
| #single | `40.17% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/reshape/merge.py](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9tZXJnZS5weQ==) | `94.19% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=footer). Last update [49ec31b...de06397](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=h1) Report
> Merging [#16436](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/49ec31bbaeca81a6f58fc1be26fe80f3ac188cdd?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16436/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #16436   +/-   ##
=======================================
  Coverage   90.42%   90.42%           
=======================================
  Files         161      161           
  Lines       51023    51023           
=======================================
  Hits        46138    46138           
  Misses       4885     4885
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <100%> (ø)` | :arrow_up: |
| #single | `40.17% <28.57%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/errors/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree#diff-cGFuZGFzL2Vycm9ycy9fX2luaXRfXy5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/reshape/merge.py](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9tZXJnZS5weQ==) | `94.18% <100%> (-0.01%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=footer). Last update [49ec31b...681a66d](https://codecov.io/gh/pandas-dev/pandas/pull/16436?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@TomAugspurger Migrated, but what would a test for this look like? Don't see any tests for the other errors in `errors/__init__.py` so not sure of right model. 
https://github.com/pandas-dev/pandas/blob/master/pandas/tests/test_errors.py

these are really tested that well 
mainly overall integration tests (e.g. we use them)
so i think prob ok

just make a note that we moved it

@jreback thanks. Added to test_errors and squashed. 
can you add a note in whatsnew (Other API Changes section is fine). otherwise lgtm. ping on green.
@nickeubank Thanks!