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

Update checkedCast in JS/TS #2553

Merged
merged 3 commits into from
Jul 24, 2024

Conversation

bernardnormier
Copy link
Member

Fixes #2323 in JS/TS.

Copy link
Member

@pepone pepone left a comment

Choose a reason for hiding this comment

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

Looks good

Comment on lines 503 to 504
.catch((ex) => {
if (ex instanceof FacetNotExistException) {
r.resolve(null);
} else {
r.reject(ex);
}
r.reject(ex);

Choose a reason for hiding this comment

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

Is this still necessary?
My understanding is that Promise::catch is only called for rejected promises anyways.
So this feels alot like a pointless catch(ex) { throw ex; }

Copy link
Member

Choose a reason for hiding this comment

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

we can write it as:

prx.ice_isA(this.ice_staticId(), ctx).then(
            (ret) => r.resolve(ret ? new this(prx) : null),
            (ex) => r.reject(ex),
        );

Choose a reason for hiding this comment

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

Ah yes, because r is a different promise than the one being returned by the ice_isA operation. I'd missed that before.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated code using Jose's suggestion, except without parenthesis around ret and ex.

@bernardnormier bernardnormier merged commit f857687 into zeroc-ice:main Jul 24, 2024
17 checks passed
@bernardnormier bernardnormier deleted the js-checkedCast branch December 9, 2024 17:08
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
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.

Consider Forwarding FacetNotExistException through checkedCasts
3 participants