Cesium: Replace explicit checks for DeveloperErrors with calls to the new Check type

Created on 31 Dec 2016  路  4Comments  路  Source: CesiumGS/cesium

4726 introduced a new private class, Check, with static utility functions to do common parameter validation and throw a DeveloperError. Using Check instead of explicit hand-coded conditionals is more concise. For example:

if (!defined(cartesian)) {
    throw new DeveloperError('cartesian is required');
}

becomes

Check.typeOf.object('cartesian', cartesian);

4726 also updated Cartesian3 to use Check.

We still want to update the rest of the Cesium codebase to use Check when reasonable (very specific checks for DeveloperErrors can still be hand-coded). This is a great beginner issue.

  • Start with the fundamental numeric types in the Core directory: cartesian, matrices, quaternions, etc.
  • Open a pull request for one file at a time to start.
  • Verify the reference documentation for the @exceptions is still correct and that there are unit tests for the exceptions in the corresponding Spec file (try the WebStorm plugin to flip between the source and spec file).
category - architecture / api cleanup good first issue

Most helpful comment

@WilliamKHo @moneimne @omh1280 @AnimatedRNG Let's work on these to start. Open a separate pull request for each file to start.

@rahwang would you like to do the first round of reviews for these?

All these files are in the Core directory. For any checks that involve arrays, just use Check.defined as there is not a Check.typeOf.array. Some checks may also require using Check.typeOf.number.lessThan and related functions.

@WilliamKHo

  • [x] arrayRemoveDuplicates
  • [x] AttributeCompression (fix any of the "____ is required" checks, skip others)
  • [x] AxisAlignedBoundingBox
  • [x] barycentricCoordinates

@moneimne

  • [x] binarySearch
  • [x] BingMapsGeocoderService
  • [x] BoxGeometry
  • [x] BoxOutlineGeometry

@omh1280

  • [x] Cartesian2 (fix just the "left and right are required" checks)
  • [x] Cartesian3 (fix just the "____ is required" checks)
  • [x] Cartographic
  • [x] CartographicGeocoderService

@AnimatedRNG

  • [ ] Event
  • [ ] Color
  • [ ] Ellipsoid - skip "Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)"
  • [ ] Geometry - skip "All attribute lists must have the same number of attributes"

All 4 comments

@shehzan10

  • [x] Matrix2
  • [x] Matrix4
  • [x] Cartesian4
  • [x] Spherical

@austinEng

  • [x] Matrix3
  • [x] Cartesian2
  • [x] Quaternion
  • [x] Rectangle

All of these files are in the Core directory.

@WilliamKHo @moneimne @omh1280 @AnimatedRNG Let's work on these to start. Open a separate pull request for each file to start.

@rahwang would you like to do the first round of reviews for these?

All these files are in the Core directory. For any checks that involve arrays, just use Check.defined as there is not a Check.typeOf.array. Some checks may also require using Check.typeOf.number.lessThan and related functions.

@WilliamKHo

  • [x] arrayRemoveDuplicates
  • [x] AttributeCompression (fix any of the "____ is required" checks, skip others)
  • [x] AxisAlignedBoundingBox
  • [x] barycentricCoordinates

@moneimne

  • [x] binarySearch
  • [x] BingMapsGeocoderService
  • [x] BoxGeometry
  • [x] BoxOutlineGeometry

@omh1280

  • [x] Cartesian2 (fix just the "left and right are required" checks)
  • [x] Cartesian3 (fix just the "____ is required" checks)
  • [x] Cartographic
  • [x] CartographicGeocoderService

@AnimatedRNG

  • [ ] Event
  • [ ] Color
  • [ ] Ellipsoid - skip "Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)"
  • [ ] Geometry - skip "All attribute lists must have the same number of attributes"

I'd be happy to @lilleyse !

@WilliamKHo @moneimne @omh1280

When you open a pull request for any of these, please tag. Ping if you need help!

@rms13

  • [ ] PolygonPipeline
  • [x] GeographicTilingScheme
  • [x] sampleTerrain
  • [ ] EncodedCartesian3
  • [x] TimeInterval
  • [x] Fix home button to work with 2D view (#5561)

@Rudraksha20

  • [x] TileAvailability
  • [x] CatmullRomSpline
  • [x] loadKTX
  • [x] EllipsoidalOccluder
  • [x] Add Check.typeOf.number.equals function (#5555)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thw0rted picture thw0rted  路  4Comments

hanbollar picture hanbollar  路  4Comments

jony89 picture jony89  路  4Comments

pjcozzi picture pjcozzi  路  4Comments

JacksonBates picture JacksonBates  路  3Comments