Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add JSError.stack, add Error conformance#48

Merged
MaxDesiatov merged 3 commits into
masterswiftwasm/JavaScriptKit:masterfrom
jserror-stackswiftwasm/JavaScriptKit:jserror-stackCopy head branch name to clipboard
Sep 15, 2020
Merged

Add JSError.stack, add Error conformance#48
MaxDesiatov merged 3 commits into
masterswiftwasm/JavaScriptKit:masterfrom
jserror-stackswiftwasm/JavaScriptKit:jserror-stackCopy head branch name to clipboard

Conversation

@MaxDesiatov

@MaxDesiatov MaxDesiatov commented Sep 14, 2020

Copy link
Copy Markdown
Member

While the stack property is non-standard, it's supported in all popular browser engines and Node.js.

Unfortunately, because stack value will be different on every machine that executes it, I'm not sure how to write a good test for it, so it currently doesn't have any tests.

Also, JSError now conforms to Error. The main reasoning is that the Publisher protocol in Combine requires Error conformance on its Failure type. I think in the future it would make sense to make JSPromise compatible with Combine, so it would be great if one could propagate errors produced by JSPromise to other publishers/subscribers.

Again, JSPromise will be implemented in a separate PR.

@MaxDesiatov MaxDesiatov requested a review from a team September 14, 2020 08:50
@j-f1

j-f1 commented Sep 14, 2020

Copy link
Copy Markdown
Member

You could test that the stack is a non-empty string.

@MaxDesiatov

Copy link
Copy Markdown
Member Author

Great point, I've added the check to the test.

ref.name.string!
}

public var stack: String {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be more safe if non-standard field is exposed as String?. For example, a new JS engine may not implement this feature.

@MaxDesiatov MaxDesiatov merged commit 3220b3c into master Sep 15, 2020
@MaxDesiatov MaxDesiatov deleted the jserror-stack branch September 15, 2020 08:46
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.