0

I'm upgrading Crashlytics sdk from Fabric to Firebase for Unity3d project and trying to adapt api-changing for exceptions catching.

I need to construct Exception instance from next arguments:

void OnLogMessageReceived(String log, String stackTrace, LogType type)

Now I have

Crashlytics.Log(log);
Crashlytics.Log(stackTrace);

Exception exception = new Exception(type);
Crashlytics.LogException(exception);

Is it possible to send stackTrace and get it pretty structured like it was in Fabric?

orion_tvv
  • 1,681
  • 4
  • 17
  • 29
  • Is this a dupe of [Attach StackTrace To Exception](https://stackoverflow.com/questions/37093261/attach-stacktrace-to-exception-without-throwing-in-c-sharp-net)? – stuartd Sep 20 '19 at 15:56

2 Answers2

0

This is Zubair from Fabric/Firebase. With the release of Firebase Crashlytics for Unity, Developers already using the Fabric Crashlytics SDK might need to make some minor changes to their code when upgrading to Firebase Crashlytics. This guide will provide details on the specific changes to the API, the reason for the change, and helpful suggestions where workarounds are required.

Zubair
  • 525
  • 4
  • 13
0

This Wrapper works well:

    class WrappedException : Exception
    {
        private string oldStackTrace;

        public WrappedException(string message, string stackTrace) : base(message)
        {
            this.oldStackTrace = stackTrace;
        }

        public override string StackTrace
        {
            get
            {
                return this.oldStackTrace;
            }
        }
    }


    void OnLogMessageReceived(String log, String stackTrace, LogType type)
    {
        var exception = new WrappedException(type, stackTrace);
        Crashlytics.LogException(exception);
    }

orion_tvv
  • 1,681
  • 4
  • 17
  • 29