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

reportUserException in 7.x.x version #1143

Closed
dyomin-d opened this issue May 31, 2021 · 7 comments
Closed

reportUserException in 7.x.x version #1143

dyomin-d opened this issue May 31, 2021 · 7 comments

Comments

@dyomin-d
Copy link

Issue

I have upgraded Sentry version from 4.x.x to 7.x.x. One of the parts of my code consisted of the following command:

Client.shared?.reportUserException(
                "",
                reason: reason,
                language: "",
                lineOfCode: "",
                stackTrace: stackTrace,
                logAllThreads: true,
                terminateProgram: true
            )

The main idea was to crash the app once the event is sent. However, there are no alternatives of this function in the newest version. If I use just SentrySDK.crash() , it won't send my custom error. Let me know how I may implement the same logic with the current version or please add this possibility in a new version.

@philipphofmann
Copy link
Member

Hi, maybe SentrySDK.captureException() is what you are looking for?

@dyomin-d
Copy link
Author

dyomin-d commented Jun 2, 2021

Thank you for the comment. I am currently using SentrySDK.capture(exception: ) , however:

  1. It isn't possible to crash the app during the capturing.
  2. Also, I can't set language, stackTrace and etc. properly, only via setExtras but in fact it doesn't pass the data like it has been earlier.

@philipphofmann
Copy link
Member

If you want to crash the app you can use SentrySDK.crash(). To add context to an event, please make use of the Scope. For more details please read our migration guide.

@philipphofmann
Copy link
Member

I consider this question as answered. Feel free to open the issue again.

@dyomin-d
Copy link
Author

I am afraid that SentrySDK.crash() doesn't fulfill our needs. It just crashes the app with default logs. However, I have used reportUserException with crash inside for different purposes e.g. get the breadcrumbs, stackTrace.

You may check the differences how it worked on 4.X.X version and the one with SentrySDK.crash()

@philipphofmann
Copy link
Member

Hey @dyomin-d,

the whole SDK concept changed a lot from 4.x.x to 7.x.x. You don't need to specify, the reason, language, lineOfCode, stackTrace, and logAllThreads anymore, if you enable SentryOptions.attachStacktrace, which is enabled by default when using captureException. If you want to make sure, that your event is sent before crashing you would have to call SentrySDK.flush(), which we didn't implement yet. You can upvote here #1013 to give this a higher priority.

@philipphofmann
Copy link
Member

Maybe you can describe your use case a bit better so I can maybe point out another solution. I don't fully understand why you want to terminate your application after you captured an error.

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

2 participants