@@ -0,0 +1,2605 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.%0Apackage com.yahoo.restapi;%0A%0Aimport com.yahoo.container.jdisc.HttpRequest;%0Aimport com.yahoo.container.jdisc.HttpResponse;%0A%0Aimport java.util.function.Function;%0A%0A/**%0A * A %7B@link RuntimeException%7D that represents a http response.%0A *%0A * @author bjorncs%0A */%0Apublic class RestApiException extends RuntimeException %7B%0A    private final int statusCode;%0A    private final HttpResponse response;%0A%0A    public RestApiException(int statusCode, String errorType, String message) %7B%0A        this(new ErrorResponse(statusCode, errorType, message), message, null);%0A    %7D%0A%0A    public RestApiException(HttpResponse response, String message) %7B%0A        this(response, message, null);%0A    %7D%0A%0A    public RestApiException(int statusCode, String errorType, String message, Throwable cause) %7B%0A        this(new ErrorResponse(statusCode, errorType, message), message, cause);%0A    %7D%0A%0A    public RestApiException(HttpResponse response, String message, Throwable cause) %7B%0A        super(message, cause);%0A        this.statusCode = response.getStatus();%0A        this.response = response;%0A    %7D%0A%0A    private RestApiException(Function%3CString, HttpResponse%3E responseFromMessage, String message, Throwable cause) %7B%0A        this(responseFromMessage.apply(message), message, cause);%0A    %7D%0A%0A    public int statusCode() %7B return statusCode; %7D%0A    public HttpResponse response() %7B return response; %7D%0A%0A    public static class NotFoundException extends RestApiException %7B%0A        public NotFoundException() %7B super(ErrorResponse::notFoundError, %22Not Found%22, null); %7D%0A    %7D%0A%0A    public static class MethodNotAllowed extends RestApiException %7B%0A        public MethodNotAllowed() %7B super(ErrorResponse::methodNotAllowed, %22Method not allowed%22, null); %7D%0A        public MethodNotAllowed(HttpRequest request) %7B%0A            super(ErrorResponse::methodNotAllowed, %22Method '%22 + request.getMethod().name() + %22' is not allowed%22, null);%0A        %7D%0A    %7D%0A%0A    public static class BadRequest extends RestApiException %7B%0A        public BadRequest(String message) %7B super(ErrorResponse::badRequest, message, null); %7D%0A        public BadRequest(String message, Throwable cause) %7B super(ErrorResponse::badRequest, message, cause); %7D%0A    %7D%0A%0A    public static class InternalServerError extends RestApiException %7B%0A        public InternalServerError(String message) %7B super(ErrorResponse::internalServerError, message, null); %7D%0A        public InternalServerError(String message, Throwable cause) %7B super(ErrorResponse::internalServerError, message, cause); %7D%0A    %7D%0A%7D%0A

Add exception type for restapi error responses