You can send information about errors and crashes you experience in you application to your Countly server to investigate them later.
To understand how you can leverage Crashes in your dashboard check here.
Handled Error Reporting
These are anticipated errors handled within your application without causing any crashes (non fatal).
try{
...
}
catch(ex){
Countly.q.push(['log_error', ex, {"custom key":"custom value"}]);
}try{
...
}
catch(ex){
Countly.log_error(ex, {"custom key":"custom value"});
}Countly.sharedInstance().crashes().recordHandledException(Exception exception);NSException* myException = [NSException exceptionWithName:@"MyException" reason:@"MyReason" userInfo:@{@"custom key":@"custom value"}];
[Countly.sharedInstance recordException:myException];let myException : NSException = NSException.init(name:NSExceptionName(rawValue: "MyException"), reason:"MyReason", userInfo:["custom key":"custom value"])
Countly.sharedInstance().recordException(myException)try{
...
}
catch(ex){
Countly.log_error(ex);
}Countly.logException(String exception, bool nonfatal, [Map<String, Object> segmentation])try {
...
} catch (e) {
await Countly.sharedInstance().crashes.recordHandledException(e as Error, { 'custom key': 'custom value' });
}Countly.logException(stack, nonfatal, customSegments);Dictionary<string, string> customInfo = new Dictionary<string, string>{
{ "custom key", "custom value" }
};
try {
...
} catch (Exception ex) {
Countly.RecordException(ex.Message, ex.StackTrace, customInfo, false);
}await Countly.Instance.CrashReports.SendCrashReportAsync(ex.Message, ex.StackTrace, null, false); Countly.instance().crashes().recordHandledException(Throwable t, Map<String, Object> segment);std::map<std::string, std::string> segmentation = {
{"custom key", "custom value"},
};
std::map<std::string, std::any="std::any"> crashMetrics;
/*mandatory values*/
crashMetrics["_os"] = "Android"; # your OS info
crashMetrics["_app_version"] = "1.22";
/*any optional info*/
crashMetrics["_cpu"] = "armv7";
/*If you somehow can capture unhandled errors set third param to false*/
countly.crash().recordException("title", "stackTrace", true, crashMetrics, segmentation);Not supported.
curl --request POST \
--url 'https://YOUR_SERVER/i?app_key=APP_KEY&device_id=DEVICE_ID' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"crash": {
"_os": "Android",
"_os_version": "4.1",
"_manufacture": "Samsung",
"_device": "Galaxy S4",
"_resolution": "1900x1080",
"_app_version": "2.1",
"_cpu": "armv7",
"_opengl": "2.1",
"_ram_current": 1024,
"_ram_total": 4096,
"_disk_current": 3000,
"_disk_total": 10240,
"_bat": 99,
"_orientation": "portrait",
"_root": false,
"_online": true,
"_muted": false,
"_background": false,
"_name": "Null Pointer exception",
"_error": "Some error stack here",
"_nonfatal": true,
"_logs": "logs provided here",
"_run": 180,
"_custom": {
"facebook_sdk": "3.5",
"admob": "6.5"
}
}
}'
You should expect the response to be:
# 200
{
"result": "Success"
}
Unhandled Error Reporting
These are unexpected errors which stem can from your application, operating system or even hardware. These will usually result in a crash (fatal) unless they are handled with an intermediary mechanism (like a framework). These are collected automatically by SDK (if possible) after you enable the feature.
Countly.q.push(['track_errors', {"custom key": "custom value"}])Countly.track_errors({"custom key": "custom value"})config.enableCrashReporting();You can use Android SDK alongside another crash SDK. For handled errors, simply pass them to both. For unhandled errors, Android only allows one handler, though handlers can be chained. Since there's no guarantee the OS will allow enough time for all handlers to process, initialize Countly last.
config.features = @[CLYCrashReporting];config.features = [CLYCrashReporting]Out of Memory (OOM) Crashes: Terminations due to low memory cannot be considered regular exceptions in iOS or Android, so it is not possible to catch and report them through standard crash handling.
Countly.track_errors()config.enableCrashReporting()config.crashes.enableCrashReporting();
Enabling crash reporting also installs the unhandled exception listener automatically.
config.enableCrashReporting();Not supported.
Enabled by default. Can be disabled via:
config.DisableAutomaticCrashReporting();config.disableUnhandledCrashReporting();Not supported.
Unhandled error tracking can be enabled from initialization template:
Same with handled errors but to report an error as unhandled, set the _nonfatal parameter to false.
curl --request POST \
--url 'https://YOUR_SERVER/i?app_key=APP_KEY&device_id=DEVICE_ID' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"crash": {
...
"_nonfatal": true,
...
}
}'
You should expect the response to be:
# 200
{
"result": "Success"
}