- Pods
- AF-BedSheet 0.0.10
- API
- ErrProcessors
- Src
sourceafBedSheet::ErrProcessors.fan
using afIoc::StrategyRegistry
** Holds a collection of `ErrProcessor`s.
**
** pre>
** @Contribute { serviceType=ErrProcessors# }
** static Void contributeErrProcessors(MappedConfig conf) {
** conf[Err#] = CatchAllErrHandler()
** }
** <pre
**
** @uses a MappedConfig of 'Type:ErrProcessor' where 'Type' is a subclass of 'Err' or a mixin.
const mixin ErrProcessors {
@NoDoc
abstract Obj processErr(Err err)
}
internal const class ErrProcessorsImpl : ErrProcessors {
private const StrategyRegistry errProcessorStrategy
internal new make(Type:ErrProcessor errProcessors) {
errProcessors.keys.each |type| {
if (type.isClass && !type.fits(Err#))
throw BedSheetErr(BsMsgs.errProcessorsNotErrType(type))
}
this.errProcessorStrategy = StrategyRegistry(errProcessors)
}
override Obj processErr(Err err) {
get(err.typeof).process(err)
}
private ErrProcessor get(Type errType) {
return errProcessorStrategy.findBestFit(errType)
}
}