createErrorZone function
Zone
createErrorZone({
- String uncaughtErrorTitle = 'Unhandled exception:',
- bool printErrorToStderr = true,
- OnUncaughtError? onUncaughtError,
- Zone? parentZone,
Creates an error Zone.
- The
uncaughtErrorTitle
to use when printing error (ifonUncaughtError
is not provided). - If
printErrorToStderr
istrue
, prints toSTDERR
(ifonUncaughtError
is not provided). onUncaughtError
is the function to handle uncaught errors. If not provided, prints error.
See printZoneError.
Implementation
Zone createErrorZone({
String uncaughtErrorTitle = 'Unhandled exception:',
bool printErrorToStderr = true,
OnUncaughtError? onUncaughtError,
Zone? parentZone,
}) {
var zoneId = ++_errorZoneIDCount;
var zoneSpecification = ZoneSpecification(
handleUncaughtError: (self, parent, zone, error, stackTrace) =>
_handleUncaughtError(uncaughtErrorTitle, printErrorToStderr,
onUncaughtError, self, parent, zone, error, stackTrace),
);
parentZone ??= Zone.current;
var zone = parentZone
.fork(specification: zoneSpecification, zoneValues: {'zoneID': zoneId});
return zone;
}