BUG/API: Catch exceptions in _ipython_display_
State: closed

We raise an UnserializeableWarning when we fail to generate
the table schema and do not publish a `table_schema` repr.

closes https://github.com/pandas-dev/pandas/issues/15996

Labels:
name: IO JSON
description: read_json, to_json, json_normalize
name: MultiIndex

Comments:
cc @rgbkrk so users get a `pandas.errors.UnserializableWarning` (open to better names here) if there's something we can't handle. The data published won't contain a `application/vnd.dataresource+json` key.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=h1) Report
> Merging [#16132](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/8d122e633a6b08e3f9dfad80050da42d789210d4?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #16132      +/-   ##
==========================================
- Coverage   90.86%   90.84%   -0.03%     
==========================================
  Files         159      159              
  Lines       50771    50777       +6     
==========================================
- Hits        46133    46126       -7     
- Misses       4638     4651      +13
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.62% <100%> (-0.03%)` | :arrow_down: |
| #single | `40.33% <28.57%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/errors/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=tree#diff-cGFuZGFzL2Vycm9ycy9fX2luaXRfXy5weQ==) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `91.31% <100%> (+0.02%)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `63.54% <0%> (-1.82%)` | :arrow_down: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `90.68% <0%> (-0.35%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16132?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/16132?src=pr&el=footer). Last update [8d122e6...37c7ad0](https://codecov.io/gh/pandas-dev/pandas/pull/16132?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Looks good to me, this is completely appropriate behavior and informs the user as to what happened better than before. 👍 
Small question: is it worth to add a special Warning for this (instead of using just UserWarning)? 

In the sense that, if we intend to actually solve this issue in an upcoming release (certainly if we want this as the default repr this will be needed), then it is maybe not needed to add the special class (which we have to keep for compat afterwards). 
If we foresee that we have to keep this warning for a longer time, then I am totally fine with it!
> Small question: is it worth to add a special Warning for this (instead of using just UserWarning)?

Yeah, I went back and forth on this. In the end I went with a special warning since we may always have some things that can't be represented with the spec (maybe), and it's a bit easier to filter just this warning if you want. I'm open to changing it to a builtin warning though.