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

org.davidmoten.oa3.codegen.spring.runtime.ServiceException Maven / Gradle / Ivy

The newest version!
package org.davidmoten.oa3.codegen.spring.runtime;

import java.util.Optional;

import org.springframework.http.ResponseEntity;

public final class ServiceException extends Exception {

    private static final long serialVersionUID = -4115693210890378905L;

    private final int statusCode;
    private final Optional> response;

    private ServiceException(int statusCode, String message, Optional> response) {
        super(message);
        this.statusCode = statusCode;
        this.response = response;
    }

    public ServiceException(int statusCode, String message) {
        this(statusCode, message, Optional.empty());
    }

    public ServiceException(int statusCode, Throwable e) {
        super(e);
        this.statusCode = statusCode;
        this.response = Optional.empty();
    }

    public ServiceException(ResponseEntity response) {
        this(response.getStatusCodeValue(), response.getStatusCode().toString(), Optional.of(response));
    }

    public int statusCode() {
        return statusCode;
    }

    public Optional> response() {
        return response;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy