question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Factor out "defer" usage for better error handling

See original GitHub issue

Cesium uses defer throughout the codebase as a remnant from when we were using when.js. However, the recommended best practice is to use new Promise constructor directly because it makes it much harder to let an exception escape. Functions passed to the construct should only reject the promise, never throw.

https://github.com/CesiumGS/cesium/pull/10149 excluded several specs in Cesium3DTilesetSpec, GltfLoaderSpec, TimeDynamicPointCloudSpec, and ModelExperimentalSpec which can be re-enabled once errors are better handled as a result of this change.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
lilleysecommented, Mar 17, 2022

I’m not entirely sure yet, but I don’t think so. So far it seems it can be handled internally and we just need to move around where the caller is actually handling the promises.

Ok that doesn’t sound too bad. I was imagining that a larger restructuring would be needed.

I agree Model.js will have similar problems. What do you think the timeline is for removing it? Maybe we can leave defer there until its replaced by ModelExperimental. It’s not causing issues in the specs like the loaders are currently.

We’re aiming to remove it in June. Holding off until ModelExperimental replaces it sounds good.

0reactions
sanjeetsuhagcommented, Jul 13, 2022

@ggetz 3 areas remain:

Read more comments on GitHub >

github_iconTop Results From Across the Web

When defer func evaluates its parameters - Stack Overflow
Ok I just figured out. If you pass any parameters to the defer func (like the 2nd defer function above), those parameters are...
Read more >
Handling Errors from Deferred Functions in Go
Being able to defer functions is a powerful feature. But with the Go error handling pattern, it can be easy to ignore errors....
Read more >
Error Handling with Panic, Recovery and Defer Statement in Go
A Golang tutorial showing developers how to handle errors using panic, recovery, and defer. Learn with code examples.
Read more >
More Gotchas of Defer in Go, Part II | Hacker News
Yeah, I generally feel the same way. For fairly simple use, scope is more consistent (all scopes / closures are identical), but func...
Read more >
The "exceeded the max defers and failures per hour" message
# This single retry rule applies to all domains and all errors. It specifies retries every 15 minutes for 2 hours, then increasing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found