Include source name in invalid GeoJSON error #8113
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When supplying invalid data to a GeoJSON source, include the source name in the
error message for easier debugging.
Before PR:
As the stacktrace is heavily async, we don't get an immediate indication of where in userland code the error originated. It can be any one of the user-defined sources. The only way to figure which source is the erroneous one, one needs to put a breakpoint on the line logging the error (as it's not an exception), and search up the async stack trace. A bit cumerbose for a bug that's usually "whoops I gave the wrong object".
After PR:
Nothing but sunshine and kittens, as we can see the source name being supplied invalid GeoJSON we can search our code, and only if needed debug up the stack trace.
This PR unfortunately only covers some of the invalid GeoJSON errors, there is another one in a mapbox dependency (geojson-vt), which of course does not know about sources and layers and all that fun. So the following call:
Will still show the less fun errors. As there are many ways to solve that error (daisy-chaning an error message defined in the caller with the original error, change the error to a null return value and check that, ...), how would you think it best be done?
Thanks.
Launch Checklist