added RemoteApiException
This commit is contained in:
@@ -9,10 +9,8 @@ import java.util.Map;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestClient;
|
import org.springframework.web.client.RestClient;
|
||||||
|
|
||||||
import com.vaessl.app.exception.ConnectionNotFoundException;
|
|
||||||
import com.vaessl.app.exception.EmptyCredentialsException;
|
import com.vaessl.app.exception.EmptyCredentialsException;
|
||||||
import com.vaessl.app.search.SearchRequest;
|
import com.vaessl.app.exception.RemoteApiException;
|
||||||
import com.vaessl.app.search.SearchResponse;
|
|
||||||
|
|
||||||
import static com.vaessl.app.connection.Endpoint.*;
|
import static com.vaessl.app.connection.Endpoint.*;
|
||||||
|
|
||||||
@@ -60,8 +58,7 @@ public class HomeboxConnectionProvider implements ConnectionProvider {
|
|||||||
.body(HomeboxLoginResponse.class);
|
.body(HomeboxLoginResponse.class);
|
||||||
|
|
||||||
if (hbResponse == null) {
|
if (hbResponse == null) {
|
||||||
throw new IllegalStateException(
|
throw new RemoteApiException(request.appUrl());
|
||||||
"Remote API returned an empty body for " + request.appUrl());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> attachmentToken = new HashMap<>();
|
Map<String, Object> attachmentToken = new HashMap<>();
|
||||||
|
|||||||
@@ -58,4 +58,10 @@ public class GlobalExceptionHandler {
|
|||||||
return ProblemDetail.forStatusAndDetail(BAD_REQUEST_EMPTY_FIELDS.getStatus(),
|
return ProblemDetail.forStatusAndDetail(BAD_REQUEST_EMPTY_FIELDS.getStatus(),
|
||||||
BAD_REQUEST_EMPTY_FIELDS.getMessage() + " " + e.getMissingFields());
|
BAD_REQUEST_EMPTY_FIELDS.getMessage() + " " + e.getMissingFields());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(RemoteApiException.class)
|
||||||
|
public ProblemDetail handleRemoteApiException(RemoteApiException e) {
|
||||||
|
return ProblemDetail.forStatusAndDetail(REMOTE_API_EMPTY_RESPONSE.getStatus(),
|
||||||
|
REMOTE_API_EMPTY_RESPONSE.getMessage() + e.getAppUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.vaessl.app.exception;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RemoteApiException extends RuntimeException {
|
||||||
|
|
||||||
|
private final String appUrl;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user