Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include source name in invalid GeoJSON error #8113

Merged
merged 1 commit into from
Apr 3, 2019

Conversation

Zirak
Copy link
Contributor

@Zirak Zirak commented Apr 3, 2019

When supplying invalid data to a GeoJSON source, include the source name in the
error message for easier debugging.

Before PR:
Error and stack trace without a source name, before the 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:
Error and stack trace showing the source name, after the 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:

map.addSource('awesomesauce', { type: 'bazinga' });

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

  • briefly describe the changes in this PR
  • write tests for all new functionality (n/a? no existing tests for this error AFAICT)
  • manually test the debug page

When supplying invalid data to a GeoJSON source, include the source name in the
error message for easier debugging.
@mourner mourner merged commit 1c19b64 into mapbox:master Apr 3, 2019
@mourner
Copy link
Member

mourner commented Apr 3, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants