mapbox / mapbox/mapbox-gl-js

[master ticket] Improve error handling

Open
#9,485 0 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

## Motivation

There are quite a few open tickets that deal with a need to improve error handling in GL JS. These fall into several categories ranging from adding more specific detail to existing errors to adding new errors to better style validation. The goal of this ticket is to summarize the existing issues into categories and drive discussion of general improvements and refactors to error handling.

**Better Error Messages**
- [ ] Add an error message for calling "GeoJSONSource#setData" for a style that doesn't exist https://github.com/mapbox/mapbox-gl-js/issues/2602
- [ ] Validation errors for layer properties should include layer id #4108
- [ ] Improve validation error messages relating to even/odd number of arguments #6437
- [x] instanceof errors in IE 11 #6733
- [ ] Provide more information about errors in mapbox #9314

**Better Error Handling**
- [ ] isSourceLoaded returns error instead of false #9430

**Update Error Type**
- [ ] Make error handling in style consistent https://github.com/mapbox/mapbox-gl-js/issues/3879
- [ ] contextmenu events not captured on Chrome for Android #7136

**Emit New Error**
- [ ] Display better message + emit error when bad args are passed to map camera events https://github.com/mapbox/mapbox-gl-js/issues/4385
- [ ] Do not handle video loading errors https://github.com/mapbox/mapbox-gl-js/issues/5646
- [ ] Missing Mapbox access token for a Mapbox source does not trigger the map.on('error') event #6528
- [ ] iOS Safari Console Error 'Unhandled Promise Rejection: AbortError: Fetch is aborted' #8480
- [ ] Print console warning for maps that use RTL text without RTL text plugin #6136

**Validation**
- [ ] Color validation doesn't evaluate channel values #6467
- [ ] Display the value of `layer.id` on validation #8455
- [ ] Improve expression type checking error for "match" #5220

**Better Docs**
- [ ] Clarify type validation error message for == expression #6387

The below sections are TBD
NOTES:
- should all possible errors be routed through GL JS Error class?
- what are the performance concerns of try/catch blocks?
- would we have to wrap every conceivable browser call?
## Design Alternatives

## Design

### Mock-Up

### Concepts

### Implementation

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

Review the linked tickets grouped under Better Error Messages, Better Error Handling, Update Error Type, Emit New Error, Validation, and Better Docs. Start with the referenced GL JS error cases such as GeoJSONSource#setData, map.on('error'), and validation messages; done requires an agreed design and implementation scope, which this ticket currently leaves TBD.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.