优化后端代码质量基础
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { logError, logInfo, logWarn } from '../../utils/logger.js'
|
||||
import { createHttpError } from '../../utils/http.js'
|
||||
import {
|
||||
getCloudtentaclesHealthJob,
|
||||
getScheduledJobsConfig,
|
||||
@@ -53,7 +54,10 @@ export async function runScheduledJobNow(jobId: unknown) {
|
||||
const job = config.jobs.find((item) => String(item.id || '').trim() === String(jobId || '').trim())
|
||||
|
||||
if (!job) {
|
||||
throw new Error('定时任务不存在')
|
||||
throw createHttpError('定时任务不存在', {
|
||||
statusCode: 404,
|
||||
errorCode: 'scheduled_job_not_found',
|
||||
})
|
||||
}
|
||||
|
||||
const currentTimer = timers.get(job.id)
|
||||
@@ -171,7 +175,10 @@ function dispatchJob(job: JsonObject) {
|
||||
return runCloudtentaclesHealthJob(job)
|
||||
}
|
||||
|
||||
throw new Error(`不支持的定时任务类型:${job.type}`)
|
||||
throw createHttpError(`不支持的定时任务类型:${job.type}`, {
|
||||
statusCode: 400,
|
||||
errorCode: 'unsupported_scheduled_job_type',
|
||||
})
|
||||
}
|
||||
|
||||
function updateJobState(jobId: string, patch: JsonObject) {
|
||||
|
||||
Reference in New Issue
Block a user