createErrorZone function
Zone
createErrorZone({
- String uncaughtErrorTitle = 'Unhandled exception:',
- bool printErrorToStderr = true,
- OnUncaughtError? onUncaughtError,
- Zone? parentZone,
Creates an error Zone.
- The
uncaughtErrorTitleto use when printing error (ifonUncaughtErroris not provided). - If
printErrorToStderristrue, prints toSTDERR(ifonUncaughtErroris not provided). onUncaughtErroris 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;
}