All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jn.agileway.springboot.web.rest.exceptionhandler.SpringServerExceptionHandler Maven / Gradle / Ivy

There is a newer version: 3.1.12
Show newest version
package com.jn.agileway.springboot.web.rest.exceptionhandler;

import com.jn.agileway.http.rest.RestActionException;
import com.jn.agileway.http.rest.RestActionExceptionHandler;
import com.jn.agileway.http.rest.RestActionExceptions;
import com.jn.agileway.web.rest.AbstractServletRestActionExceptionHandler;
import com.jn.langx.http.rest.RestRespBody;
import org.springframework.beans.ConversionNotSupportedException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.support.MissingServletRequestPartException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
@RestActionExceptions({
        @RestActionException(ConversionNotSupportedException.class),
        @RestActionException(ConversionNotSupportedException.class),
        @RestActionException(HttpMessageNotWritableException.class),
        @RestActionException(MissingServletRequestPartException.class)
})
public class SpringServerExceptionHandler extends AbstractServletRestActionExceptionHandler {
    @Override
    public RestRespBody handle(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        request.setAttribute("javax.servlet.error.exception", ex);
        return RestRespBody.error500("HTTP-500", ex.getMessage());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy