microsoft / appcenter-sdk-apple

Development repository for the App Center SDK for iOS, macOS and tvOS.
Other
565 stars 224 forks source link

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

Closed daleswift closed 11 months ago

daleswift commented 11 months ago

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
MikhailSuendukov commented 11 months ago

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

daleswift commented 11 months ago

Steps to reproduce:

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

MikhailSuendukov commented 11 months ago

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.

radekwilczak commented 11 months ago

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?

MikhailSuendukov commented 11 months ago

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