CesiumGS / CesiumGS/cesium

Provide exception free failure paths for constructors that parse strings.

Open
#3,716 1 comment 0 reactions 0 assignees View on GitHub
category - architecture / api type - enhancement
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

Cesium is pretty aggressive about throwing `DeveloperError` for invalid input; but a lot of the time developer's themselves aren't in control of that input. For example, having `JulianDate.fromIso8601` and `TimeInterval.fromIso8601` throw is great for developer hard-coded string literals but inconvenient for user supplied input. Even if we switched to `RuntimeError` in these cases, that doesn't really solve the problem. For functions that parse strings, we should provide a way to attempt to parse input without throwing an exception (and perhaps have it return undefined instead). We could make this an option on the `from` functions themselves, or we could add `try` versions, such as `JulianDate.tryFromIso8601` (though this is very much a .NET convention). I'm not sure if there are any standard idioms for stuff like this in JavaScript, but a little bit of searching did not reveal much. Adding an extra option to not throw might be our best bet.

Anyone else have ideas here?

Contributor guide

Open the contributing guide

Research direction

The issue names JulianDate.fromIso8601 and TimeInterval.fromIso8601 as parsing entry points. Review those constructors and the repository's existing string-parsing conventions first, then determine the non-throwing API shape and its expected behavior for invalid input. Done requires an agreed design and corresponding coverage for the affected parsing paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
developer-experience, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.