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

Support for preconditionFailure message #132

Closed
mattyohe opened this issue Feb 6, 2017 · 4 comments
Closed

Support for preconditionFailure message #132

mattyohe opened this issue Feb 6, 2017 · 4 comments

Comments

@mattyohe
Copy link
Contributor

mattyohe commented Feb 6, 2017

Calls to Swift's preconditionFailure (and likely its friends assertionFailure, fatalError etc) that occur in 5.6.5 do not appear to bubble up the message parameter for reporting in the stack trace that is viewable on Bugsnag.com.

It is unclear to me if this is a deficiency in Bugsnag or Swift.

Example:
Calling the code below in an application that uses Bugsnag:

public var name: String {
  preconditionFailure("Example of an error")
}

Would produce a trace similar to:

0  MyApp               name.get (MyApp.swift:10:20)

But the message "Example of an error" would not be reported.

@kattrali
Copy link
Contributor

Interesting. Thanks for the report, @mattyohe. I'll look into it 🕵️‍♀️

@kattrali
Copy link
Contributor

It looks like there's no message because the provided text isn't attached to the exception in some way, and is only printed. preconditionFailure, fatalError, et cetera call _assertionFailure, which prints the message using _swift_stdlib_reportFatalErrorInFile before terminating execution using Builtin.int_trap().

For now, I don't see how we can support this, but its something to revisit in the future and potentially discuss on the mailing list, as I think we can make the function arguments more accessible.

@edenman
Copy link

edenman commented Jul 18, 2017

Is there a different method we should call instead of fatalError to get the message to propagate on a forced crash?

@edenman
Copy link

edenman commented Jul 18, 2017

Also FWIW the Sentry guys seem to have figured out how to extract the message: https://github.com/getsentry/sentry-cocoa/pull/188/files

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

No branches or pull requests

3 participants