Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import org.springframework.web.reactive.function.client.WebClientException;
import org.springframework.web.reactive.function.client.WebClientRequestException;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -53,8 +54,8 @@ public AiSummaryResult fetchSummary(UUID contentId, String text, String thumbnai
throw new DevpickException(ErrorCode.AI_SERVER_ERROR);
}
return result;
} catch (WebClientResponseException e) {
throw new DevpickException(ErrorCode.AI_SERVER_ERROR);
} catch (WebClientException e) {
throw toDevpickException(e);
}
}

Expand Down Expand Up @@ -82,8 +83,16 @@ public AiQuizResult fetchQuiz(UUID contentId, String text) {
throw new DevpickException(ErrorCode.AI_SERVER_ERROR);
}
return result;
} catch (WebClientResponseException e) {
throw new DevpickException(ErrorCode.AI_SERVER_ERROR);
} catch (WebClientException e) {
throw toDevpickException(e);
}
}

private DevpickException toDevpickException(WebClientException e) {
if (e instanceof WebClientRequestException requestEx
&& requestEx.getCause() instanceof java.util.concurrent.TimeoutException) {
return new DevpickException(ErrorCode.AI_TIMEOUT);
}
return new DevpickException(ErrorCode.AI_SERVER_ERROR);
}
}
Loading