errorInfo static method

Map<String, Object?>? errorInfo(
  1. Object? error,
  2. StackTrace? stackTrace
)

ErrorInfo for an error object / stack trace (null when both absent).

Implementation

static Map<String, Object?>? errorInfo(Object? error, StackTrace? stackTrace) {
  if (error == null && stackTrace == null) return null;
  var stack = stackTrace;
  if (stack == null && error is Error) stack = error.stackTrace;
  String? text;
  if (error != null) {
    try {
      text = error.toString();
    } catch (_) {
      text = error.runtimeType.toString();
    }
  }
  return buildErrorInfo(
    type: error?.runtimeType.toString(),
    message: text == null ? null : capString(text, 64 * 1024),
    stack: stack == null ? null : capString(stack.toString(), _maxStackChars),
  );
}