captureError static method

Future<void> captureError(
  1. Object error,
  2. String tag
)

Captures an error or exception with an exception tag.

This method should be called to log errors and exceptions in the application. The error will be sent to DevRev for tracking and analysis.

@param error The error to be captured. Can be an Error, Exception, or String. If it's an Error or Exception, the message and stack trace will be automatically extracted. @param tag A tag to categorize the exception (e.g., "network", "database").

@remarks Make sure that you have called the configure(appID) method before.

Implementation

static Future<void> captureError(Object error, String tag) {
  String errorMessage;
  String? stackTrace;

  if (error is Error) {
    errorMessage = error.toString();
    stackTrace = error.stackTrace?.toString();
  } else if (error is Exception) {
    errorMessage = error.toString();
    stackTrace = null;
  } else {
    errorMessage = error.toString();
    stackTrace = null;
  }

  return DevRevSDKPlatform.instance.captureError(
    errorMessage,
    stackTrace,
    tag,
  );
}