MCPcopy Create free account
hub / github.com/lightdash/lightdash / tryJobStep

Method tryJobStep

packages/backend/src/models/JobModel/JobModel.ts:175–202  ·  view source on GitHub ↗
(
        jobUuid: string,
        jobStepType: JobStepType,
        callback: () => Promise<T>,
    )

Source from the content-addressed store, hash-verified

173 }
174
175 async tryJobStep<T>(
176 jobUuid: string,
177 jobStepType: JobStepType,
178 callback: () => Promise<T>,
179 ): Promise<T> {
180 try {
181 await this.startJobStep(jobUuid, jobStepType);
182
183 const result = await callback();
184
185 await this.updateJobStep(
186 jobUuid,
187 JobStepStatusType.DONE,
188 jobStepType,
189 );
190 return result;
191 } catch (e) {
192 await this.updateJobStep(
193 jobUuid,
194 JobStepStatusType.ERROR,
195 jobStepType,
196 getErrorMessage(e),
197 e instanceof DbtError ? e.logs : [],
198 );
199 await this.update(jobUuid, { jobStatus: JobStatusType.ERROR });
200 throw e; // throw the error again
201 }
202 }
203}

Callers 3

_createMethod · 0.80
testAndCompileProjectMethod · 0.80
onLockAcquiredMethod · 0.80

Calls 4

startJobStepMethod · 0.95
updateJobStepMethod · 0.95
updateMethod · 0.95
getErrorMessageFunction · 0.90

Tested by

no test coverage detected