Handled exceptions in Cocoa apps
In addition to automatically reporting your app's crashes, Apptics allows you to log handled exceptions (non-fatal).
- You can find all the non-fatal under Quality > Non-fatal in the left menu.
- The summary contains the total number of non-fatal, unique users, devices, and a total percentage of exception-free users.
Logging handled exceptions
- To log a handled exception, use the APTrackException method. This method will capture the exception and log it in Apptics allowing you to track & analyze.
CopiedNSMutableArray *array = [[NSMutableArray alloc] init];
@try {
NSString *string = [array objectAtIndex:10];
} @catch (NSException *exception) {
APTrackException(exception);
}
Copiedlet array = NSMutableArray()
do {
let string = try array.object(at: 10) as! String
} catch let exception as NSException {
APTrackException(exception)
}
Logging errors
- The APTrackError method allows to log custom errors along with the relevant details such as the error message, code, and additional properties.
CopiedNSError *error = [NSError errorWithDomain:@"com.yourdomain.app"
code:404
userInfo:@{NSLocalizedDescriptionKey:@"Resource not found"}];
APTrackError(error);
Copiedlet error = NSError(domain: "com.yourdomain.app", code: 404, userInfo: [NSLocalizedDescriptionKey: "Resource not found"])
APTrackError(error)
In the above example, Error object (NSError) represents the error that occurred. You can provide details such as the domain, code, and user-friendly description.
IMPORTANT:
- The APTrackException and APTrackError methods are used to log handled exceptions and errors. This can be helpful when you want to catch and report the crashes without causing the app to crash.
- Error context: It is important to provide meaningful error information. This can be the error domain, code, and a descriptive message.
- Make sure to use this method to capture meaningful exceptions and errors that provide insights into your app's stability.