thegamedefault
09/23/2025, 11:10 AMVaibhav (BAML 🐑)
09/23/2025, 6:34 PMbaml-sam
09/23/2025, 9:18 PMbaml-sam
09/23/2025, 9:22 PMerror: invalid_argument | client_error | validation_failure | finish_reason_error | client_http_error | internal_errorthegamedefault
09/24/2025, 6:28 AMbaml-sam
09/24/2025, 6:42 AMthegamedefault
09/24/2025, 10:45 AM@Data
public class AIException extends RuntimeException {
private final HttpStatus httpStatus;
private final AIServiceError error;
public AIException(ApiException e) {
super(e.getMessage());
this.httpStatus = HttpStatus.valueOf(e.getCode());
this.error = ObjectMapperUtility.readValue(e.getResponseBody(), AIServiceError.class);
}
}
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class AIServiceError {
private String error;
private String prompt;
@JsonProperty("raw_output")
private String rawOutput;
private String message;
@Getter
@RequiredArgsConstructor
public enum ErrorType {
VALIDATION_FAILURE("validation_failure");
private final String value;
public static ErrorType fromValue(String value) {
return Arrays.stream(ErrorType.values()).filter(errorType -> errorType.value.equals(value))
.findAny().orElse(null);
}
}
}