mapbox / mapboxgl-jupyter

Use Mapbox GL JS to visualize data in a Python Jupyter notebook
MIT License
661 stars 136 forks source link

Propagate errors from Mapbox GL JS #62

Open ryanbaumann opened 6 years ago

ryanbaumann commented 6 years ago

Problem

The Mapbox GL JS library has tons of built-in error checking for tokens, styles, and sources. In order to provide relevant and useful error messages to a user creating a visualization, we'd have to re-create many error checks in the Python mapboxgl library.

Proposal

Propagate errors that affect the visualization (invalid token, invalid Mapbox style sheet, missing source, etc) and throw them from the python mapboxgl code execution. We wouldn't want to propagate all types of errors - only ones that prevent a valid data visualization layer from being drawn on the map, or from the map being initialized.

Reference PR by @EtienneDesticourt - https://github.com/mapbox/mapboxgl-jupyter/pull/59#issuecomment-371403399

@perrygeo @sgillies, any thoughts on this approach?

sgillies commented 6 years ago

@ryanbaumann Sounds like a good idea to me. A Python exception is way better than map that never renders. I'm really interested in seeing how it would be done!