Skip to content

Commit 7f27c94

Browse files
committed
fix: enhance error handling for get-image-generation-job-status endpoint
1 parent 7d1fab4 commit 7f27c94

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,24 @@ export default class UploadPlugin extends AdminForthPlugin {
472472
server.endpoint({
473473
method: 'POST',
474474
path: `/plugin/${this.pluginInstanceId}/get-image-generation-job-status`,
475-
handler: async ({ body, adminUser, headers }) => {
475+
handler: async ({ body, adminUser, headers, response }) => {
476476
const jobId = body.jobId;
477477
if (!jobId) {
478-
return { error: "Can't find job id" };
478+
response.setStatus(400);
479+
return { ok: false, error: "Can't find job id" };
479480
}
480481
const job = jobs.get(jobId);
481482
if (!job) {
482-
return { error: "Job not found" };
483+
response.setStatus(404);
484+
return { ok: false, error: "Job not found" };
485+
}
486+
if (job.status === 'failed' || job.error) {
487+
response.setStatus(500);
488+
489+
return {
490+
ok: false,
491+
job,
492+
};
483493
}
484494
return { ok: true, job };
485495
}

0 commit comments

Comments
 (0)