java类org.springframework.boot.autoconfigure.web.ErrorAttributes的实例源码

BootJpaApplication.java 文件源码 项目:spring-boot-jpa 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Customized ErrorAttribute bean.
 * We really need to find a cleaner way of handling these error messages.
 *
 * @return customized ErrorAttributes
 */
@Bean
public ErrorAttributes errorAttributes() {
    return new DefaultErrorAttributes() {

        @Override
        public Map<String, Object> getErrorAttributes(
                final RequestAttributes requestAttributes,
                final boolean includeStackTrace) {
            Map<String, Object> attributes = super
                    .getErrorAttributes(requestAttributes, includeStackTrace);
            Throwable error = getError(requestAttributes);

            if (error instanceof MethodArgumentNotValidException) {
                MethodArgumentNotValidException ex =
                        ((MethodArgumentNotValidException) error);
                attributes.put("errors", ex.getMessage());
            }

            return attributes;
        }
    };
}
CustomErrorControllerConfiguration.java 文件源码 项目:spring-mvc-error-handling-example 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 抄的是{@link ErrorMvcAutoConfiguration#basicErrorController(ErrorAttributes)}
 *
 * @param errorAttributes
 * @return
 */
@Bean
public CustomErrorController customErrorController(ErrorAttributes errorAttributes) {
  return new CustomErrorController(
      errorAttributes,
      this.serverProperties.getError(),
      this.errorViewResolvers
  );
}
BindExceptionErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 28 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(BindException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    return buildErrorData(ex.getBindingResult())
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .withThrowable(ex)
            .build();
}
MethodArgumentNotValidErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 30 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(MethodArgumentNotValidException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    return buildErrorData(ex.getBindingResult())
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .withThrowable(ex)
            .build();
}
SecurityErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 36 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(T ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    String requestHeaders = getRequestHeaders(requestAttributes);
    return buildErrorData(ex, requestHeaders)
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .build();
}
ThrowableErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 34 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(Throwable ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    return buildErrorData(ex, defaultResponseStatus)
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .withResponseStatus(defaultResponseStatus)
            .build();
}
HttpClientErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 33 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(T ex, HttpServletRequest request, HttpStatus responseHttpStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    return buildErrorData(ex, responseHttpStatus)
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .build();
}
ExternalHttpRequestErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 31 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(ExternalHttpRequestException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    return buildErrorData(ex, ex.getStatusCode())
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .build();
}
ApplicationErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 36 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(ApplicationException ex, HttpServletRequest request, HttpStatus defaultResponseStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    String requestUri = getRequestUri(errorAttributes, requestAttributes);
    return buildErrorData(ex)
            .withRequestMethod(request.getMethod())
            .withRequestUri(requestUri)
            .build();
}
ServletFilterErrorHandler.java 文件源码 项目:errorest-spring-boot-starter 阅读 31 收藏 0 点赞 0 评论 0
public ServletFilterErrorHandler(ErrorAttributes errorAttributes, ServerProperties serverProperties, ErrorsFactory errorsFactory, ErrorDataProviderContext providerContext) {
    super(errorAttributes, emptyList());
    this.errorAttributes = errorAttributes;
    errorProperties = serverProperties.getError();
    this.errorsFactory = errorsFactory;
    this.providerContext = providerContext;
}
TraceWebFilterAutoConfiguration.java 文件源码 项目:https-github.com-g0t4-jenkins2-course-spring-boot 阅读 34 收藏 0 点赞 0 评论 0
public TraceWebFilterAutoConfiguration(TraceRepository traceRepository,
        TraceProperties traceProperties,
        ObjectProvider<ErrorAttributes> errorAttributesProvider) {
    this.traceRepository = traceRepository;
    this.traceProperties = traceProperties;
    this.errorAttributes = errorAttributesProvider.getIfAvailable();
}
SearchBoxConfiguration.java 文件源码 项目:searchbox-core 阅读 33 收藏 0 点赞 0 评论 0
@Bean
public ErrorAttributes customizeErrorResponseAttributes() {

    return new DefaultErrorAttributes(){
        @Override
        public Map<String, Object> getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
            Map<String, Object> errorAttributes = super.getErrorAttributes(requestAttributes, includeStackTrace);
            errorAttributes.remove("timestamp");
            errorAttributes.remove("exception");
            return errorAttributes;
        }
    };

}
TraceWebFilterAutoConfiguration.java 文件源码 项目:spring-boot-concourse 阅读 38 收藏 0 点赞 0 评论 0
public TraceWebFilterAutoConfiguration(TraceRepository traceRepository,
        TraceProperties traceProperties,
        ObjectProvider<ErrorAttributes> errorAttributesProvider) {
    this.traceRepository = traceRepository;
    this.traceProperties = traceProperties;
    this.errorAttributes = errorAttributesProvider.getIfAvailable();
}
EndpointWebMvcChildContextConfiguration.java 文件源码 项目:contestparser 阅读 37 收藏 0 点赞 0 评论 0
@Bean
@ConditionalOnBean(ErrorAttributes.class)
public ManagementErrorEndpoint errorEndpoint(ServerProperties serverProperties,
        ErrorAttributes errorAttributes) {
    return new ManagementErrorEndpoint(serverProperties.getError().getPath(),
            errorAttributes);
}
ErrorControllerTest.java 文件源码 项目:OpenConext-pdp 阅读 26 收藏 0 点赞 0 评论 0
@Before
public void before() {
    this.errorAttributes = mock(ErrorAttributes.class);

    Map<String, Object> result = new HashMap<>();
    result.put("exception", "exception");
    result.put("message", "message");

    when(errorAttributes.getErrorAttributes(any(), anyBoolean())).thenReturn(result);

    this.subject = new ErrorController(errorAttributes);
}
SkipperServerConfiguration.java 文件源码 项目:spring-cloud-skipper 阅读 26 收藏 0 点赞 0 评论 0
@Bean
public ErrorAttributes errorAttributes() {
    // override boot's DefaultErrorAttributes
    return new SkipperErrorAttributes();
}
ErrorResource.java 文件源码 项目:emergentmud 阅读 35 收藏 0 点赞 0 评论 0
@Inject
public ErrorResource(ErrorAttributes errorAttributes) {
    super(errorAttributes);

    this.errorAttributes = errorAttributes;
}
CustomErrorController.java 文件源码 项目:myfavor 阅读 46 收藏 0 点赞 0 评论 0
public CustomErrorController(ErrorAttributes errorAttributes) {
    super(errorAttributes);
}
CrnkErrorController.java 文件源码 项目:crnk-framework 阅读 41 收藏 0 点赞 0 评论 0
public CrnkErrorController(ErrorAttributes errorAttributes,
        ErrorProperties errorProperties) {
    super(errorAttributes, errorProperties);
}
CrnkErrorController.java 文件源码 项目:crnk-framework 阅读 32 收藏 0 点赞 0 评论 0
public CrnkErrorController(ErrorAttributes errorAttributes,
        ErrorProperties errorProperties,
        List<ErrorViewResolver> errorViewResolvers) {
    super(errorAttributes, errorProperties, errorViewResolvers);
}
CrnkErrorControllerAutoConfiguration.java 文件源码 项目:crnk-framework 阅读 28 收藏 0 点赞 0 评论 0
@Bean
@ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT)
public BasicErrorController jsonapiErrorController(ErrorAttributes errorAttributes) {
    return new CrnkErrorController(errorAttributes, this.serverProperties.getError(), this.errorViewResolvers);
}
ZuulErrorController.java 文件源码 项目:counter-cloud 阅读 35 收藏 0 点赞 0 评论 0
public ZuulErrorController(ErrorAttributes errorAttributes) {
    super(errorAttributes);
}
CustomErrorController.java 文件源码 项目:spring-mvc-error-handling-example 阅读 34 收藏 0 点赞 0 评论 0
public CustomErrorController(ErrorAttributes errorAttributes,
    ErrorProperties errorProperties) {
  super(errorAttributes, errorProperties);
}
CustomErrorController.java 文件源码 项目:spring-mvc-error-handling-example 阅读 29 收藏 0 点赞 0 评论 0
public CustomErrorController(ErrorAttributes errorAttributes,
    ErrorProperties errorProperties,
    List<ErrorViewResolver> errorViewResolvers) {
  super(errorAttributes, errorProperties, errorViewResolvers);
}
CustomErrorAttributesConfiguration.java 文件源码 项目:spring-mvc-error-handling-example 阅读 36 收藏 0 点赞 0 评论 0
@Bean
public ErrorAttributes errorAttributes() {
  return new CustomErrorAttributes();
}
DemoErrorController.java 文件源码 项目:SpringBootStudy 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 初始化ExceptionController
 */
@Autowired
public DemoErrorController(ErrorAttributes errorAttributes) {
    Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
    this.errorAttributes = errorAttributes;
}
MissingServletRequestParameterErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 30 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(MissingServletRequestParameterException ex, HttpServletRequest request, HttpStatus responseHttpStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    return super.getErrorData(ex, request, BAD_REQUEST, errorAttributes, requestAttributes);
}
ServletRequestBindingErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 32 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(ServletRequestBindingException ex, HttpServletRequest request, HttpStatus responseHttpStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    return super.getErrorData(ex, request, BAD_REQUEST, errorAttributes, requestAttributes);
}
NoHandlerFoundErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 41 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(NoHandlerFoundException ex, HttpServletRequest request, HttpStatus responseHttpStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    return super.getErrorData(ex, request, NOT_FOUND, errorAttributes, requestAttributes);
}
TypeMismatchErrorDataProvider.java 文件源码 项目:errorest-spring-boot-starter 阅读 36 收藏 0 点赞 0 评论 0
@Override
public ErrorData getErrorData(TypeMismatchException ex, HttpServletRequest request, HttpStatus responseHttpStatus, ErrorAttributes errorAttributes, RequestAttributes requestAttributes) {
    return super.getErrorData(ex, request, BAD_REQUEST, errorAttributes, requestAttributes);
}


问题


面经


文章

微信
公众号

扫码关注公众号