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

Improve handling of export errors #409

Closed

Conversation

WCByrne
Copy link
Contributor

@WCByrne WCByrne commented Mar 8, 2019

Wrap native export calls in try catch and convert native exceptions to more helpful error messages.

Converting the native errors seemed to be the easiest way to handle this.

See: https://sketch-friends.slack.com/archives/C5YKGT26B/p1552063120097100

@bohemian-coding-danger
Copy link
Collaborator

Warnings
⚠️ This pull request may need a CHANGELOG entry.
⚠️

Source/dom/export.js changed, but not:

  • 📚 its docs

That's OK as long as you're refactoring.

Generated by 🚫 dangerJS

// export the layers
if (layers.length) {
exporter.exportLayers(layers)
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not too sure about wrapping everything in try/catch. That breaks any optimizations the compiler can make.

I'd rather explicitly check for it:

if (!nativeObjects.parentPage()) {
  throw error
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started going that route but then realized there are some edge cases in there. For example, some cases don't need a parent. This seemed less likely to cause conflicts if the internals were to change (except the error messages of course but that is covered by the tests).

Any idea what that difference in optimizations would be? Significant for this?

@christianklotz
Copy link
Contributor

Closing for now. May revisit at a later point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants