Skip to content

Commit

Permalink
Enhance debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
datakurre committed Sep 22, 2023
1 parent 7961160 commit 47f24f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARTIFACT_NAME = camunda-rcc-worker
ARTIFACT_VERSION ?= 0.8.2-3
ARTIFACT_VERSION ?= 0.8.2-4
ARTIFACT_FULLNAME ?= $(ARTIFACT_NAME)-$(ARTIFACT_VERSION).tar.gz
REPOSITORY ?= nomad-local

Expand Down
23 changes: 23 additions & 0 deletions carrot_rcc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,11 @@ const subscribe = (topic: string) => {

try {
// Prepare robot
LOG.debug("Preparing task", task.topicName, task.id);
const files = await load(task, tasksDir, itemsDir, topic);

// Execute robot
LOG.debug("Executing task", task.topicName, task.id);
await new Promise((resolve, reject) => {
const stdout: string[] = [];
const stderr: string[] = [];
Expand Down Expand Up @@ -770,6 +772,7 @@ const subscribe = (topic: string) => {
LOG.debug(data.toString());
});
exec.on("close", async (code) => {
LOG.debug("Executing task exit code", code, task.topicName, task.id);
let errorMessage = "error";
if (code !== null && code > 0 && code < 251) {
errorMessage = await failReason(tasksDir);
Expand All @@ -784,12 +787,15 @@ const subscribe = (topic: string) => {
stderr.join(""),
code || 0
);
LOG.debug("Result collection completed", task.topicName, task.id);
} catch (e) {
LOG.debug("Result collection failed", task.topicName, task.id);
LOG.error(`${e}`);
stderr.push(`${e}`);
code = 255; // Unexpected error
}
if (code === 0) {
LOG.debug("Completing task...", task.topicName, task.id);
const relpath = path.join(itemsDir, "items.release.json");
const release = fs.existsSync(relpath)
? JSON.parse(fs.readFileSync(relpath) as unknown as string)
Expand All @@ -804,13 +810,23 @@ const subscribe = (topic: string) => {
release?.exception?.type === "BUSINESS"
) {
// RPA.Robocorp.WorkItems.Release with business error
LOG.debug(
"Completing task with business error",
task.topicName,
task.id
);
await taskService.handleBpmnError(
task,
release?.exception?.code || null,
release?.exception?.message || null
);
} else if (release?.state === "FAILED") {
// RPA.Robocorp.WorkItems.Release with application error
LOG.debug(
"Completing task with technical failure",
task.topicName,
task.id
);
await taskService.handleFailure(task, {
errorMessage:
release?.exception?.code ||
Expand All @@ -821,9 +837,15 @@ const subscribe = (topic: string) => {
retryTimeout,
});
} else {
LOG.debug(
"Completing task with success",
task.topicName,
task.id
);
await taskService.complete(task);
}
} catch (e) {
LOG.debug("Completing task failed", task.topicName, task.id);
LOG.error(`${e}`);
stderr.push(`${e}`);
code = 255; // Unexpected error
Expand Down Expand Up @@ -881,6 +903,7 @@ const subscribe = (topic: string) => {
});
});
} catch (e: any) {
LOG.debug("Completed task with failure", task.topicName, task.id);
LOG.debug(e);
await taskService.handleFailure(task, {
errorMessage: `${e?.error?.message ?? e}`,
Expand Down

0 comments on commit 47f24f9

Please sign in to comment.