printZoneError function
void
printZoneError(
- Object error,
- StackTrace stackTrace, {
- String? title,
- String? message,
- bool printErrorToStderr = true,
Prints an error and stackTrace.
See printToZoneStderr.
Implementation
void printZoneError(
Object error,
StackTrace stackTrace, {
String? title,
String? message,
bool printErrorToStderr = true,
}) {
var s = StringBuffer();
s.write(
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n',
);
if (title != null) {
s.write('$title\n\n');
}
var errorMsg = error.toString().trim();
s.write('$errorMsg\n\n');
s.write('StackTrace:\n$stackTrace\n');
if (message != null && message.isNotEmpty) {
s.write(
'------------------------------------------------------------------------------\n\n',
);
s.write('$message\n');
}
s.write(
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n',
);
if (printErrorToStderr) {
printToZoneStderr(s);
} else {
print(s);
}
}