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

cc.shacocloud.mirage.web.exception.HttpMessageNotReadableException Maven / Gradle / Ivy


package cc.shacocloud.mirage.web.exception;

import cc.shacocloud.mirage.web.http.HttpMessageConverter;
import cc.shacocloud.mirage.web.HttpRequest;
import org.jetbrains.annotations.Nullable;
import org.springframework.util.Assert;

/**
 * 当{@link HttpMessageConverter#read}方法失败时,由{@link HttpMessageConverter}抛出。
 */
@SuppressWarnings("serial")
public class HttpMessageNotReadableException extends HttpMessageConversionException {

    @Nullable
    private final HttpRequest request;

    @Deprecated
    public HttpMessageNotReadableException(String msg) {
        super(msg);
        this.request = null;
    }

    @Deprecated
    public HttpMessageNotReadableException(String msg, @Nullable Throwable cause) {
        super(msg, cause);
        this.request = null;
    }

    public HttpMessageNotReadableException(String msg, @Nullable HttpRequest request) {
        super(msg);
        this.request = request;
    }

    public HttpMessageNotReadableException(String msg, @Nullable Throwable cause,
                                           @Nullable HttpRequest request) {
        super(msg, cause);
        this.request = request;
    }


    /**
     * 返回原始的{@link HttpRequest}
     */
    public HttpRequest getRoutingContext() {
        Assert.state(this.request != null, "没有request可用!");
        return this.request;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy