Report Handled Exceptions
Send caught exceptions to UXCam from your Xamarin / MAUI app
A handled exception is one your code catches, so the app keeps running. Send it to UXCam with ReportExceptionEvent to see how often it happens, which users hit it, and the session where it happened.
You can attach properties as key-value pairs, for example screen=checkout or reason=invalid_quantity.
The examples below use the UXCamDotNet 1.1.6 package. The method is on the UXCam class in the Com.UXCam namespace, and its parameters differ between Android and iOS.
Android
Pass the .NET exception as it is. UXCam converts it for the Android SDK.
void UXCam.ReportExceptionEvent(Exception exception)
void UXCam.ReportExceptionEvent(Exception exception, Dictionary<string, object> properties)iOS
The iOS SDK takes an NSException. Create one from the .NET exception. Properties are optional; pass null to send none.
void UXCam.ReportExceptionEvent(NSException exception, NSDictionary properties)Example for both platforms
using Com.UXCam;
#if IOS
using Foundation;
#endif
try
{
PlaceOrder(quantity);
}
catch (Exception ex)
{
#if ANDROID
UXCam.ReportExceptionEvent(ex, new Dictionary<string, object>
{
{ "screen", "checkout" },
{ "quantity", quantity }
});
#elif IOS
var exception = new NSException(ex.GetType().Name, ex.Message, null);
var properties = NSDictionary.FromObjectsAndKeys(
new object[] { "checkout", quantity.ToString(), ex.StackTrace ?? "" },
new object[] { "screen", "quantity", "stack_trace" });
UXCam.ReportExceptionEvent(exception, properties);
#endif
}
NoteAn
NSExceptioncreated in code has no native stack trace. On iOS, add the .NET stack trace as a property, as in the example, if you want to see it in UXCam.
Older versionsBefore 1.1.2, the Android method only takes a
Java.Lang.Throwable. Convert the exception withJava.Lang.Throwable.FromException(ex), or update the package.
Updated about 2 hours ago
What's Next? ...
Send caught exceptions to UXCam from your Xamarin / MAUI app
