printStackTrace method

void printStackTrace([
  1. bool useErrorPrint = false
])

Extension on Throwable to support printing stack traces in a unified way.

Useful when catching general JetLeaf exceptions:

catch (e) {
  if (e is Throwable) {
    e.printStackTrace();
  }
}

Implementation

void printStackTrace([bool useErrorPrint = false]) {
  if (useErrorPrint) {
    Error.safeToString(toString()).split('\n').forEach(print);
  } else {
    print(toString());
  }
}