mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
refactor(bedrock-agentcore): extract shared error/JSON helpers into BedrockAgentCoreControllerSupport (#3637)
BedrockAgentCoreControlController, GatewayController, GatewayRuleController, IdentityController, MemoryController, ResourcePolicyController, and ToolsController each carried their own byte-for-byte identical copy of error(Exception, String) (AwsException maps to a structured JSON body with an X-Amzn-Errortype header, anything else falls back to a 400 ValidationException), the single most duplicated area CPD found across src/main. Three of them (Control, Gateway, Memory) also carried an identical stringMap(JsonNode) JSON-object-to-map helper, and four (Control, Gateway, Identity, Memory) carried an identical text(JsonNode, String) field-extraction helper found along the way. Extracted all three into a new package-private BedrockAgentCoreControllerSupport. Each controller keeps its own private error/stringMap/text methods as one-line delegations (error still takes the caller's own LOG so log lines keep attributing to the right controller), so no call site elsewhere in any of the seven files needed to change. putInstant deliberately stays out: it's duplicated too, but it's two genuinely different behaviors (ISO-8601 strings for runtimes and gateways, epoch seconds for workload identities and memories) wearing the same method name, not one shared behavior. Merging it would risk conflating the two. While here, also finished what #3556 started delegating: BedrockAgentCoreMemoryController had its own separate awsError(AwsException) doing the exact same thing as error(), added for the new event endpoints. Routed those four call sites through the existing error() method instead and removed the duplicate. Also fixed BedrockAgentCoreMemoryController's import block, which had non-java/java.util imports interleaved into the jakarta.ws.rs group. No behavior change. Removing AwsErrorResponse/AwsException/HashMap imports that became unused after the extraction where applicable. Full bedrockagentcorecontrol and bedrockagentcore test suites (95 tests) pass unchanged. Three of the seven controllers (GatewayRule, ResourcePolicy, Tools) have no existing test coverage at all; manually verified the delegated error() renders identical ValidationException/ResourceNotFoundException responses on ResourcePolicyController before removing the verification test, since adding permanent coverage for previously-untested controllers is a separate concern from this issue's scope.
This commit is contained in:
1 parent
4707d4d3a8
commit
3c96327ac4
8 files changed
+93
-152
No files matched your search
+3
-24
@@ -4,8 +4,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -29,7 +27,6 @@ import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -409,8 +406,7 @@ public class BedrockAgentCoreControlController {
|
||||
}
|
||||
|
||||
private static String text(JsonNode node, String field) {
|
||||
JsonNode v = node.get(field);
|
||||
return (v == null || v.isNull()) ? null : v.asText();
|
||||
return BedrockAgentCoreControllerSupport.text(node, field);
|
||||
}
|
||||
|
||||
private static JsonNode obj(JsonNode node, String field) {
|
||||
@@ -419,27 +415,10 @@ public class BedrockAgentCoreControlController {
|
||||
}
|
||||
|
||||
private static Map<String, String> stringMap(JsonNode node) {
|
||||
if (node == null || !node.isObject()) {
|
||||
return null;
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
node.fields().forEachRemaining(e -> map.put(e.getKey(), e.getValue().asText()));
|
||||
return map;
|
||||
return BedrockAgentCoreControllerSupport.stringMap(node);
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package io.github.hectorvent.floci.services.bedrockagentcorecontrol;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Helpers shared by the sibling REST controllers under this package (control, gateway, gateway
|
||||
* rule, identity, memory, resource policy, tools). Each used to carry its own copy of the same
|
||||
* error-response builder and JSON-to-map conversion, found duplicated by CPD across all seven.
|
||||
*
|
||||
* <p>{@code putInstant} deliberately stays out of here: different AgentCore resource types encode
|
||||
* timestamps differently (ISO-8601 strings for runtimes, epoch seconds for workload identities and
|
||||
* memories), so unlike {@code error} and {@code stringMap}/{@code text}, that one isn't actually
|
||||
* one shared behavior wearing several copies, it's genuinely different behavior per resource type.
|
||||
*/
|
||||
final class BedrockAgentCoreControllerSupport {
|
||||
|
||||
private BedrockAgentCoreControllerSupport() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an exception as this protocol's REST JSON error response: an {@link AwsException}
|
||||
* maps directly to its own status/code/message, anything else falls back to a 400
|
||||
* {@code ValidationException} and gets logged under the caller's own logger so log lines still
|
||||
* attribute to the right controller.
|
||||
*/
|
||||
static Response error(Logger log, Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
log.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Converts a JSON object node into a flat string map, or null when node isn't an object. */
|
||||
static Map<String, String> stringMap(JsonNode node) {
|
||||
if (node == null || !node.isObject()) {
|
||||
return null;
|
||||
}
|
||||
Map<String, String> map = new HashMap<>();
|
||||
node.fields().forEachRemaining(e -> map.put(e.getKey(), e.getValue().asText()));
|
||||
return map;
|
||||
}
|
||||
|
||||
/** Reads a text field from a JSON node, or null when the field is absent or JSON null. */
|
||||
static String text(JsonNode node, String field) {
|
||||
JsonNode v = node.get(field);
|
||||
return (v == null || v.isNull()) ? null : v.asText();
|
||||
}
|
||||
}
|
||||
+5
-24
@@ -4,8 +4,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -28,6 +26,7 @@ import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
/** Standard-REST endpoints for AgentCore gateways and gateway targets. */
|
||||
@Path("/gateways")
|
||||
@@ -293,8 +292,7 @@ public class BedrockAgentCoreGatewayController {
|
||||
}
|
||||
|
||||
private static String text(JsonNode node, String field) {
|
||||
JsonNode v = node.get(field);
|
||||
return (v == null || v.isNull()) ? null : v.asText();
|
||||
return BedrockAgentCoreControllerSupport.text(node, field);
|
||||
}
|
||||
|
||||
private static JsonNode obj(JsonNode node, String field) {
|
||||
@@ -302,28 +300,11 @@ public class BedrockAgentCoreGatewayController {
|
||||
return (v == null || v.isNull() || v.isMissingNode()) ? null : v;
|
||||
}
|
||||
|
||||
private static java.util.Map<String, String> stringMap(JsonNode node) {
|
||||
if (node == null || !node.isObject()) {
|
||||
return null;
|
||||
}
|
||||
java.util.Map<String, String> map = new java.util.HashMap<>();
|
||||
node.fields().forEachRemaining(e -> map.put(e.getKey(), e.getValue().asText()));
|
||||
return map;
|
||||
private static Map<String, String> stringMap(JsonNode node) {
|
||||
return BedrockAgentCoreControllerSupport.stringMap(node);
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
}
|
||||
+1
-14
@@ -3,7 +3,6 @@ package io.github.hectorvent.floci.services.bedrockagentcorecontrol;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -139,18 +138,6 @@ public class BedrockAgentCoreGatewayRuleController {
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
}
|
||||
+2
-16
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -326,8 +325,7 @@ public class BedrockAgentCoreIdentityController {
|
||||
}
|
||||
|
||||
private static String text(JsonNode node, String field) {
|
||||
JsonNode v = node.get(field);
|
||||
return (v == null || v.isNull()) ? null : v.asText();
|
||||
return BedrockAgentCoreControllerSupport.text(node, field);
|
||||
}
|
||||
|
||||
private static List<String> urls(JsonNode node) {
|
||||
@@ -340,18 +338,6 @@ public class BedrockAgentCoreIdentityController {
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
}
|
||||
+15
-46
@@ -4,11 +4,14 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.BedrockAgentCoreEventService;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.model.Branch;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.model.MemoryEvent;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.model.PayloadType;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcorecontrol.model.Memory;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -17,13 +20,6 @@ import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.BedrockAgentCoreEventService;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.model.Branch;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.model.MemoryEvent;
|
||||
import io.github.hectorvent.floci.services.bedrockagentcore.model.PayloadType;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
@@ -34,6 +30,9 @@ import jakarta.ws.rs.core.Response;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* AgentCore memory endpoints. The operation is a literal path suffix
|
||||
@@ -180,33 +179,15 @@ public class BedrockAgentCoreMemoryController {
|
||||
}
|
||||
|
||||
private static String text(JsonNode node, String field) {
|
||||
JsonNode v = node.get(field);
|
||||
return (v == null || v.isNull()) ? null : v.asText();
|
||||
return BedrockAgentCoreControllerSupport.text(node, field);
|
||||
}
|
||||
|
||||
private static java.util.Map<String, String> stringMap(JsonNode node) {
|
||||
if (node == null || !node.isObject()) {
|
||||
return null;
|
||||
}
|
||||
java.util.Map<String, String> map = new java.util.HashMap<>();
|
||||
node.fields().forEachRemaining(e -> map.put(e.getKey(), e.getValue().asText()));
|
||||
return map;
|
||||
private static Map<String, String> stringMap(JsonNode node) {
|
||||
return BedrockAgentCoreControllerSupport.stringMap(node);
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
|
||||
// ── AgentCore Memory events (data plane) ─────────────────────
|
||||
@@ -233,7 +214,7 @@ public class BedrockAgentCoreMemoryController {
|
||||
// AWS answers CreateEvent with 201, not 200.
|
||||
return Response.status(201).entity(Map.of("event", event)).build();
|
||||
} catch (AwsException e) {
|
||||
return awsError(e);
|
||||
return error(e, "creating event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +241,7 @@ public class BedrockAgentCoreMemoryController {
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
} catch (AwsException e) {
|
||||
return awsError(e);
|
||||
return error(e, "listing events");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +258,7 @@ public class BedrockAgentCoreMemoryController {
|
||||
return Response.ok(Map.of("event",
|
||||
eventService.getEvent(memoryId, actorId, sessionId, eventId, region))).build();
|
||||
} catch (AwsException e) {
|
||||
return awsError(e);
|
||||
return error(e, "getting event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,22 +276,10 @@ public class BedrockAgentCoreMemoryController {
|
||||
return Response.ok(Map.of("eventId",
|
||||
eventService.deleteEvent(memoryId, actorId, sessionId, eventId, region))).build();
|
||||
} catch (AwsException e) {
|
||||
return awsError(e);
|
||||
return error(e, "deleting event");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an {@link AwsException} the way this protocol needs it: the SDK maps the error by the
|
||||
* {@code X-Amzn-Errortype} header, which the shared exception mapper does not set.
|
||||
*/
|
||||
private static Response awsError(AwsException e) {
|
||||
return Response.status(e.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", e.getErrorCode())
|
||||
.entity(new AwsErrorResponse(e.getErrorCode(), e.getMessage()))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Request body of {@code CreateEvent}; {@code sessionId} and {@code branch} are optional. */
|
||||
public record CreateEventRequest(String actorId, String sessionId, Double eventTimestamp,
|
||||
List<PayloadType> payload, Branch branch) {
|
||||
|
||||
+1
-14
@@ -3,7 +3,6 @@ package io.github.hectorvent.floci.services.bedrockagentcorecontrol;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
@@ -74,18 +73,6 @@ public class BedrockAgentCoreResourcePolicyController {
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
}
|
||||
+1
-14
@@ -3,7 +3,6 @@ package io.github.hectorvent.floci.services.bedrockagentcorecontrol;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -309,18 +308,6 @@ public class BedrockAgentCoreToolsController {
|
||||
}
|
||||
|
||||
private Response error(Exception e, String action) {
|
||||
if (e instanceof AwsException aws) {
|
||||
return Response.status(aws.getHttpStatus())
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", aws.jsonType())
|
||||
.entity(new AwsErrorResponse(aws.jsonType(), aws.getMessage()))
|
||||
.build();
|
||||
}
|
||||
LOG.errorv(e, "Error {0}", action);
|
||||
return Response.status(400)
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.header("X-Amzn-Errortype", "ValidationException")
|
||||
.entity(new AwsErrorResponse("ValidationException", e.getMessage()))
|
||||
.build();
|
||||
return BedrockAgentCoreControllerSupport.error(LOG, e, action);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user