mapbox / mapbox/mapbox-gl-js

Make error handling in style consistent

Open
#3,879 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking change :warning:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Erroneous uses of the runtime styling API in some cases propagate errors by throwing (e.g. [here](https://github.com/mapbox/mapbox-gl-js/blob/fb173257e734cffa04f6636bc03b3798bdcd8a4f/js/style/style.js#L343-L343), [here](https://github.com/mapbox/mapbox-gl-js/blob/fb173257e734cffa04f6636bc03b3798bdcd8a4f/js/style/style.js#L364-L364), [here](https://github.com/mapbox/mapbox-gl-js/blob/fb173257e734cffa04f6636bc03b3798bdcd8a4f/js/style/style.js#L368-L368), [here](https://github.com/mapbox/mapbox-gl-js/blob/fb173257e734cffa04f6636bc03b3798bdcd8a4f/js/style/style.js#L396-L396)) and in other cases by emitting an `error` event (e.g. [here](https://github.com/mapbox/mapbox-gl-js/blob/fb173257e734cffa04f6636bc03b3798bdcd8a4f/js/style/style.js#L681-L681), [here](https://github.com/mapbox/mapbox-gl-js/blob/fb173257e734cffa04f6636bc03b3798bdcd8a4f/js/style/style.js#L134-L134), [here](https://github.com/mapbox/mapbox-gl-js/blob/3e56c777ca384e8443c2af889630b9a8fc0664bb/js/style/validate_style.js#L8-L8)).

We have [previously agreed](https://github.com/mapbox/mapbox-gl-js/issues/3208) that all errors should be propagated via the `error` event, so should convert the cases that throw.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the referenced cases in js/style/style.js and js/style/validate_style.js, then review issue #3208 for the agreed error-handling behavior. Convert the identified runtime styling API cases so errors are propagated through the error event instead of being thrown.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.