Skip to content

Commit 09a5f5e

Browse files
Bold Create AgentVinothSF5015
andcommitted
Return upload exceptions as JSON so the UI shows the real error
Co-authored-by: VinothSF5015 <197725877+VinothSF5015@users.noreply.github.com>
1 parent 432c7c0 commit 09a5f5e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎Document_Chunking1_New/AgentRAGWithAzure 1/AgentRAGWithAzure/Endpoints/RagEndpointExtensions.cs‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ public static IEndpointRouteBuilder MapRagEndpoints(this IEndpointRouteBuilder e
6868
async (
6969
HttpRequest request,
7070
RagService ragService,
71-
UploadQuotaService quota) =>
71+
UploadQuotaService quota,
72+
ILogger<RagService> logger) =>
7273
{
74+
try
75+
{
7376
if (!request.HasFormContentType)
7477
{
7578
return Results.BadRequest(
@@ -173,6 +176,14 @@ await ragService.IndexUploadedFileAsync(
173176
{
174177
Files = uploadedFiles
175178
});
179+
}
180+
catch (Exception ex)
181+
{
182+
logger.LogError(ex, "Upload failed.");
183+
return Results.Json(
184+
new UploadErrorResponse { Error = ex.GetType().Name + ": " + ex.Message },
185+
statusCode: StatusCodes.Status500InternalServerError);
186+
}
176187
});
177188

178189
// ------------------------------------------------------------

0 commit comments

Comments
 (0)