Beispiel #1
0
        public ApiErrorInfo Build(TEx ex, ApiErroInfoBuilderOptions options)
        {
            var message = options.LoggingLevel == ApiErroInfoBuilderOptions.LoggingLevels.Verbose ? ex.ToString() : ex.Message;
            var result  = new ApiErrorInfo(message);

            return(result);
        }
Beispiel #2
0
        public static void RegisterErrorFilter(this Container container)
        {
            container.Register <IApiErrorInfoBuilder <ValidationException>, ValidationApiErrorInfoBuilder>();
            container.Register <IApiErrorInfoBuilder <ApiException>, ApiErrorInfoBuilder>();

            container.RegisterConditional(typeof(IApiErrorInfoBuilder <>), typeof(DefaultApiErrorInfoBuilder <>), c => !c.Handled);

            var options = new ApiErroInfoBuilderOptions(ApiErroInfoBuilderOptions.LoggingLevels.Minimal);

            container.Register <IApiErrorInfoFactory>(() => new ApiErrorInfoFactory(container, options));
        }
 public ApiErrorInfoFactory(Container container, ApiErroInfoBuilderOptions defaultOptions)
 {
     _container      = container ?? throw new ArgumentNullException(nameof(container));
     _defaultOptions = defaultOptions ?? new ApiErroInfoBuilderOptions(ApiErroInfoBuilderOptions.LoggingLevels.Minimal);
 }