from static method
This method returns error
if it is a SquadronException (enriching it with workerId
and command
if it
is a WorkerException). Otherwise, it returns a new WorkerException wrapping error
and stackTrace
.
Implementation
static SquadronException from(Object error,
[StackTrace? stackTrace, String? workerId, int? command]) {
if (error is SquadronError) {
return error;
} else if (error is WorkerException) {
return error
.withCommand(command)
.withWorkerId(workerId)
.withCommand(command);
} else if (error is TimeoutException) {
return TaskTimeoutException(
message: error.message ?? 'Task timeout',
duration: error.duration,
workerId: workerId,
command: command);
} else {
return WorkerException(error.toString(),
stackTrace: stackTrace, workerId: workerId, command: command);
}
}