Skip to content

Commit ff1d09a

Browse files
committed
refactor: improve error propagation and logging throughout execution chain
Enhanced error handling to ensure detailed error information from TapisJobService.getAppArgs flows through the entire execution chain to the API layer. Improved error logging in TapisExecutionService and subTasksService to provide comprehensive debugging information while ensuring users receive meaningful error responses.
1 parent 385447e commit ff1d09a

File tree

2 files changed

+41
-22
lines changed

2 files changed

+41
-22
lines changed

src/api/api-v1/services/subTasksService.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -534,24 +534,35 @@ const subTasksService: SubTasksService = {
534534
let submissionResult: SubmissionResult = { submittedExecutions: [], failedExecutions: [] };
535535

536536
if (executionCreation.executionToBeRun.length > 0) {
537-
submissionResult = await executionService.submitExecutions(
538-
executionCreation.executionToBeRun,
539-
executionCreation.model,
540-
executionCreation.threadRegion,
541-
executionCreation.component,
542-
subtask.id,
543-
subtask.model_ensembles[w3id].id
544-
);
545-
if (submissionResult.failedExecutions.length > 0) {
546-
console.warn(
547-
"Some executions failed to submit:",
548-
submissionResult.failedExecutions
537+
try {
538+
submissionResult = await executionService.submitExecutions(
539+
executionCreation.executionToBeRun,
540+
executionCreation.model,
541+
executionCreation.threadRegion,
542+
executionCreation.component,
543+
subtask.id,
544+
subtask.model_ensembles[w3id].id
549545
);
546+
if (submissionResult.failedExecutions.length > 0) {
547+
console.warn(
548+
"Some executions failed to submit:",
549+
submissionResult.failedExecutions
550+
);
551+
// Log detailed error information for each failed execution
552+
submissionResult.failedExecutions.forEach((failedExecution) => {
553+
console.error(`Execution ${failedExecution.execution.id} failed:`, failedExecution.error.message);
554+
console.error("Full error details:", failedExecution.error);
555+
});
556+
}
557+
console.log(
558+
"Successfully submitted executions:",
559+
submissionResult.submittedExecutions.length
560+
);
561+
} catch (error) {
562+
console.error("Error during execution submission:", error instanceof Error ? error.message : String(error));
563+
console.error("Full error details:", error);
564+
throw new InternalServerError(`Failed to submit executions: ${error instanceof Error ? error.message : String(error)}`);
550565
}
551-
console.log(
552-
"Successfully submitted executions:",
553-
submissionResult.submittedExecutions.length
554-
);
555566
} else {
556567
console.log("No executions to run");
557568
}

src/classes/tapis/adapters/TapisExecutionService.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ export class TapisExecutionService implements IExecutionService {
119119
const jobId = await this.submitSingleExecution(app, seed, model, threadId);
120120
submittedExecutions.push({ execution: seed.execution, jobId });
121121
} catch (error) {
122-
console.error("Error submitting single execution", JSON.stringify(error));
122+
console.error("Error submitting single execution:", error instanceof Error ? error.message : String(error));
123+
console.error("Full error details:", error);
123124
await this.handleSingleExecutionFailure(seed, error, threadModelId);
124125

125126
const serializableError: SerializableError = {
@@ -188,13 +189,20 @@ export class TapisExecutionService implements IExecutionService {
188189
): void {
189190
if (failedExecutions.length > 0) {
190191
if (failedExecutions.length === this.seeds.length) {
191-
const all_messages = failedExecutions.forEach((fe) => {
192-
console.error(`Execution ${fe.execution.id} failed: ${fe.error.message}`);
193-
return fe.error.message;
192+
const errorMessages: string[] = [];
193+
failedExecutions.forEach((fe) => {
194+
const errorMsg = `Execution ${fe.execution.id} failed: ${fe.error.message}`;
195+
console.error(errorMsg);
196+
console.error("Full error details for execution", fe.execution.id, ":", fe.error);
197+
errorMessages.push(fe.error.message);
194198
});
195-
throw new Error("All jobs failed to submit - " + all_messages);
199+
throw new Error("All jobs failed to submit - " + errorMessages.join("; "));
196200
} else {
197-
console.warn("Some jobs failed to submit:", failedExecutions);
201+
console.warn("Some jobs failed to submit:");
202+
failedExecutions.forEach((fe) => {
203+
console.warn(`Execution ${fe.execution.id} failed: ${fe.error.message}`);
204+
console.warn("Full error details for execution", fe.execution.id, ":", fe.error);
205+
});
198206
}
199207
}
200208
}

0 commit comments

Comments
 (0)