I have this code to track errors but only for live
Crashes.TrackError(ex);
I don't want to be sending crashes on development so I have this
if (!Debugger.IsAttached) Crashes.TrackError(ex);
but the if condition is redundant so I wanted to create an extension method like
Crashes.TrackErrorLive(ex);
I tried the following code but it's not working... I've also read that extension method requires an instance
public static void TrackErrorLive(this Crashes crashes, Exception ex)
{
if (!Debugger.IsAttached) Crashes.TrackError(ex);
}
You can not create an extension method for static class. But you can create your own static class with method needed:
public static class CrashesExtensions
{
public static void TrackErrorLive(Exception ex)
{
if (!Debugger.IsAttached) Crashes.TrackError(ex);
}
}
and then use it:
CrashesExtensions.TrackErrorLive(ex);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.