plainError function

String plainError(
  1. Object error
)

error as one line a report can show: without the Exception: prefix, without colors and with its lines joined.

Implementation

String plainError(Object error) => '$error'
    .replaceAll(RegExp(r'\x1B\[[0-9;]*m'), '')
    .replaceFirst(RegExp(r'^Exception: '), '')
    .split(RegExp(r'\r?\n'))
    .map((line) => line.trim())
    .where((line) => line.isNotEmpty)
    .join(' ');