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

Model error handling #3259

Merged
merged 3 commits into from
Dec 2, 2015
Merged

Model error handling #3259

merged 3 commits into from
Dec 2, 2015

Conversation

lilleyse
Copy link
Contributor

For #3177
Related to comments in #3239

Tests for:

  • throw new RuntimeError('Unsupported glTF Extension: ' + extension);
  • throw new DeveloperError('bgltf is not a valid Binary glTF file.');
  • throw new DeveloperError('Only Binary glTF version 1 is supported. Version ' + version + ' is not.');

I added a ready promise reject test for the invalid extension spec, but the other ones throw errors in the constructor which makes it hard to reject the ready promise.

@@ -347,6 +347,8 @@ define([
this._releaseGltfJson = defaultValue(options.releaseGltfJson, false);
this._animationIds = undefined;

this._readyPromise = when.defer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For cohension, can we move this._ready = false; above or below this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean cohesion.

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 30, 2015

This is good, just that tweak if you agree.

@lilleyse
Copy link
Contributor Author

I ended up adding an optional readyPromise that you can pass in to Model, and now I'm able to test the second two cases. This is also important for batched and instanced tiles because there are cases where the Model rejects the promise in the constructor (like invalid gltf header), but the promise won't do anything because the then and otherwise haven't been assigned yet. This causes a few of my tests to fail.

Is this the right approach?

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 30, 2015

I think this is fine. @mramato do you agree?

Add reference doc (to the constructor function and Model.fromGltf) and update CHANGES.md.

@lilleyse
Copy link
Contributor Author

Do we want it to be public?

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 30, 2015

I think so. Why not? Sounds like there are valid use cases to provide this to the constructor function instead of assigning it construction.

@lilleyse
Copy link
Contributor Author

lilleyse commented Dec 1, 2015

I decided not to add the readyPromise option because it started to get messy, and instead only reject ready promises for request errors like Model originally did. Most of the code is reverted.

@lilleyse
Copy link
Contributor Author

lilleyse commented Dec 1, 2015

This is ready for review.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 2, 2015

Can you please also cherry pick the commits to Model.js and tests for a pull request into master?

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 2, 2015

Looks good.

pjcozzi added a commit that referenced this pull request Dec 2, 2015
@pjcozzi pjcozzi merged commit 21a0d35 into 3d-tiles Dec 2, 2015
@pjcozzi pjcozzi deleted the model-error-handling branch December 2, 2015 02:23
This was referenced Dec 2, 2015
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