I found a way to log custom caught exceptions in the Crashlytics Android SDK, but I can't find anything like that for the iOS SDK. Is there a way to log a caught exception with Crashlytics on iOS?
See Android explanation: http://support.crashlytics.com/knowledgebase/articles/202805-logging-caught-exceptions
You can also use Crashlytics below features to provide more information. Logging Non-Fatal Events: try { myMethodThatThrows(); } catch (Exception e) { Crashlytics. logException(e); // handle your exception here! }
Crashlytics associates the logs with your crash data and displays them in the Crashlytics page of the Firebase console, under the Logs tab. Note: To avoid slowing down your app, Crashlytics limits logs to 64kB and deletes older log entries when a session's logs go over that limit.
Mike from Crashlytics and Fabric here.
You can now capture logged NSErrors in your iOS, tvOS, or OS X app. You want to use:
[CrashlyticsKit recordError:error];
or
Crashlytics.sharedInstance().recordError(error)
This will let you capture a fair number of logged NSErrors per user session. These are only sent on app relaunch. Logged errors errors are grouped by the error domain and code. This means error issues can span many different call sites.
See Documentation
Finally Crashlytics added the desired feature 3.5.0!!
[CrashlyticsKit recordError:error];
or
Crashlytics.sharedInstance().recordError(error)
Reference
/** * * This allows you to record a non-fatal event, described by an NSError object. These events will be grouped and * displayed similarly to crashes. Keep in mind that this method can be expensive. Also, the total number of * NSErrors that can be recorded during your app's life-cycle is limited by a fixed-size circular buffer. If the * buffer is overrun, the oldest data is dropped. Errors are relayed to Crashlytics on a subsequent launch * of your application. * * You can also use the -recordError:withAdditionalUserInfo: to include additional context not represented * by the NSError instance itself. * **/ - (void)recordError:(NSError *)error; - (void)recordError:(NSError *)error withAdditionalUserInfo:(nullable CLS_GENERIC_NSDICTIONARY(NSString *, id) *)userInfo;
https://docs.fabric.io/ios/changelog.html#january-7-2016
HISTORY
This actually doesn't work as I expected: The message is saved into Crashlytics but only after the app is restarted and it will only save the last message.
So far non of the solutions mentioned here works. There is no way to track handled exceptions in iOS using Crashlytics.
You can use this to log any exception
[[Crashlytics sharedInstance] recordCustomExceptionName:@"HandledException" reason:@"Some reason" frameArray:@[]];
In Crashlytics you'll see it in the crash report but with the NON-FATALS
type.
Event if it's not it's intended usage exceptions are logged in the same way Android handled exceptions are.
This is available in version 3.0.7.
recordCustomExceptionName:reason:frameArray:
This method can be used to record a single exception structure in a report. This is particularly useful when your code interacts with non-native languages like Lua, C#, or Javascript. This call can be expensive and should only be used shortly before process termination. This API is not intended be to used to log NSException objects. All safely-reportable NSExceptions are automatically captured by Crashlytics.
https://docs.fabric.io/appledocs/Crashlytics/Classes/Crashlytics.html#//api/name/recordCustomExceptionName:reason:frameArray:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With