Source
ErrorHandlerCollection on(Type errorType, middlewareA, [middlewareB = nothing, middlewareC = nothing,
middlewareD = nothing, middlewareE = nothing, middlewareF = nothing, middlewareG = nothing,
middlewareH = nothing, middlewareI = nothing, middlewareJ = nothing, middlewareK = nothing,
middlewareL = nothing, middlewareM = nothing, middlewareN = nothing, middlewareO = nothing,
middlewareP = nothing, middlewareQ = nothing, middlewareR = nothing, middlewareS = nothing,
middlewareT = nothing, middlewareU = nothing, middlewareV = nothing, middlewareW = nothing,
middlewareX = nothing, middlewareY = nothing, middlewareZ = nothing]) {
final Iterable middlewareTokens = [middlewareA, middlewareB,
middlewareC, middlewareD, middlewareE, middlewareF, middlewareG, middlewareH,
middlewareI, middlewareJ, middlewareK, middlewareL, middlewareM, middlewareN,
middlewareO, middlewareP, middlewareQ, middlewareR, middlewareS, middlewareT,
middlewareU, middlewareV, middlewareW, middlewareX, middlewareY, middlewareZ
].where((m) => m != nothing);
for (final type in _catches.keys) {
if (reflectType(type).isSubtypeOf(reflectType(errorType))) {
throw new BadErrorHandlerOrderException(
"$type is a subtype of $errorType and should therefore be "
"added after $errorType in the handler chain.\n\n"
" ErrorHandlerMiddleware\n"
" .on($errorType, _handle$errorType)\n"
" .on($type, _handle$type);\n"
);
}
}
return new ErrorHandlerCollection(
<Type, Pipeline>{}
..addAll(_catches)
..addAll({errorType: pipeActual(resolveMiddleware(middlewareTokens))})
);
}