Skip to content

Commit f90e23d

Browse files
committed
Fix so failed cancels in the dashboard redirect back with an error message
1 parent 0cc5604 commit f90e23d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

apps/webapp/app/routes/resources.taskruns.$runParam.cancel.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { parse } from "@conform-to/zod";
22
import { ActionFunction, json } from "@remix-run/node";
33
import { z } from "zod";
44
import { prisma } from "~/db.server";
5-
import { redirectWithSuccessMessage } from "~/models/message.server";
5+
import { redirectWithErrorMessage, redirectWithSuccessMessage } from "~/models/message.server";
66
import { logger } from "~/services/logger.server";
77
import { CancelTaskRunService } from "~/v3/services/cancelTaskRun.server";
88

@@ -49,12 +49,18 @@ export const action: ActionFunction = async ({ request, params }) => {
4949
stack: error.stack,
5050
},
5151
});
52-
submission.error = { runParam: error.message };
53-
return json(submission);
52+
return redirectWithErrorMessage(
53+
submission.value.redirectUrl,
54+
request,
55+
`Failed to cancel run, ${error.message}`
56+
);
5457
} else {
5558
logger.error("Failed to cancel run", { error });
56-
submission.error = { runParam: JSON.stringify(error) };
57-
return json(submission);
59+
return redirectWithErrorMessage(
60+
submission.value.redirectUrl,
61+
request,
62+
`Failed to cancel run, ${JSON.stringify(error)}`
63+
);
5864
}
5965
}
6066
};

0 commit comments

Comments
 (0)