microsoft/appcenter-sdk-apple

Crashes.trackError always shows MSACExceptionModel.initWithError: as the exception

daleswift opened this issue · 5 comments

When calling Crashes.trackError it always displays MSACExceptionModel.initWithError: as the exception. This is because it captures a call stack trace including its own frame. The top frame of the stack is used as the headline display in Issues report

Describe the solution you'd like
The headline display for trackError should be customisable in the constructor.

Describe alternatives you've considered
As a workaround, I am capturing a call stack myself and prepending a surrogate frame to include the actual failing method, then using the constructor ExceptionModel(withType:exceptionMessage:stacktrace)

Screenshot 2023-10-19 at 10 26 17 am

Hi @daleswift and thanks for reaching out to us, could you please provide us with the steps to reproduce your error?

Steps to reproduce:

  • Create any iOS project and call Crashes.trackError
  • Check the results in AppCenter
  • The error is listed as originating in MSACExceptionModel.initWithError rather than from the actual calling code (in my example it should be ViewController.sendErrorButtonTapped)

I'm attaching a sample project. You need to replace line 16 in AppDelegate.swift
static let appCenterSecret = "your app secret here"
with a valid AppCenter secret.

Run the app and tap Send Error several times

BugSplatStoryBoard.zip

I apologize for the delay, the fact is that if the stack trace generation format does not suit you, then it is possible to send your MCAExceptionModel with a defined stack trace. Therefore, your workaround is an architecturally expected solution. I will close this issue but if you have any additional questions feel free to reopen it.

Describe alternatives you've considered As a workaround, I am capturing a call stack myself and prepending a surrogate frame to include the actual failing method, then using the constructor ExceptionModel(withType:exceptionMessage:stacktrace)

@daleswift Could you share a code example how do you creating ExceptionModel?
I mean what you exactly you are putting in withType, exceptionMessage, stacktrace params?

You can implement it in this way. In the screenshot you can see how the data in the stack trace is displayed on the portal.

    let model = ExceptionModel(withType: "MyExceptionType", exceptionMessage: "ExceptionCustomMessage", stackTrace: ["firstline fileName1 address1 className1 methodName1 somedata", "secondline fileName2 address2 className2 methodName2 somedata", "thirdline fileName2 address2 className2 methodName2 somedata"])!
    Crashes.trackException(model, properties: nil, attachments: nil)

Screenshot 2023-11-06 at 15 24 07