refactor(error): refactor standard throws to non-retryable ApplicationFailure in workflows and activities

This commit is contained in:
yiling
2026-05-28 10:43:54 +08:00
parent afeb5e9899
commit 023f256e00
7 changed files with 71 additions and 14 deletions
+7 -1
View File
@@ -1,4 +1,5 @@
import type { WorkflowTask } from '@/generated/prisma/client'
import { ApplicationFailure } from '@temporalio/workflow'
import {
getActivities,
executeActivity,
@@ -39,7 +40,12 @@ export async function transcodeMedia(task: WorkflowTask): Promise<void> {
// 2. Get Asset
const asset = await executeActivity(TaskQueueDb, getAssetActivity, task.assetId)
const key = asset?.storageKey?.key
if (!asset || !key) throw new Error('Asset not found or has no key')
if (!asset || !key) {
throw ApplicationFailure.create({
message: 'Asset not found or has no key',
nonRetryable: true,
})
}
// 3. Get Worker-Specific Queue for Transcode
workerQueue = await executeActivity(TaskQueueTranscode, getTranscodeWorkerQueueActivity)