notifyError method
Announces error and asks for an answer to it.
For the errors that have nowhere else to go: an action abandoned by JobContext.abandonable failing later, a disposer, a callback of JobContext.onCancel, Job.whenCancelled or Job.whenFinished, work handed over with JobContext.unattended. The observer hears it through JobObserver.onError, and one that is a JobAnswerer answers for it through JobAnswerer.onUnanswered; without such an observer the error goes to the zone the job was created in.
Two calls, each guarded on its own: an onError that throws does not
cost the error its answer. Both go by the walk of Job.visitErrors:
onError is told about each error inside a ParallelWaitError on its
own, and the answer is asked for each failure.
A cancellation — a Cancelled, or a ParallelWaitError carrying
nothing but cancellations — never reaches the zone from here, and
nobody is asked to answer for it: it is a decision somebody made, not a
failure. An observer hears it through onError; without one, nobody
does. Nor is anybody asked about a failure that Job.isCancellationError
names, once the job has accepted a cancellation.
Which failures go on to the answer is settled before onError hears any
of them, and onError is told so: JobErrorAnswer.answered for each of
those, JobErrorAnswer.cancellation for a cancellation and for a failure
the filter names.
See Where each error goes on the error rules page.
Implementation
@protected
void notifyError(Object error, StackTrace stackTrace) {
final verdicts = _verdicts(error, stackTrace);
// A failure the walk that took the verdicts did not meet is asked about
// by nobody.
_notifyObserver(
error,
stackTrace,
verdicts: verdicts,
otherwise: JobErrorAnswer.never,
);
_askForAnswers(error, verdicts);
}