From dd6b89b0d0b3de79d19d23cdbf506c6860f17e94 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Thu, 9 Jun 2022 23:11:47 +0500 Subject: [PATCH 1/3] fix: parse the logs before appending the request to request array when server type is sasjs --- src/job-execution/WebJobExecutor.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/job-execution/WebJobExecutor.ts b/src/job-execution/WebJobExecutor.ts index 7374ceb..dcd1feb 100644 --- a/src/job-execution/WebJobExecutor.ts +++ b/src/job-execution/WebJobExecutor.ts @@ -169,19 +169,27 @@ export class WebJobExecutor extends BaseJobExecutor { ? res.result.log.map((logLine: any) => logLine.line).join('\n') : res.result.log - const resObj = res - - if (this.serverType === ServerType.Sasjs) { - if (res.result._webout.length < 1) - throw new JobExecutionError( - 0, - 'Job execution failed', - parsedSasjsServerLog - ) - } + const resObj = + this.serverType === ServerType.Sasjs + ? { + result: res.result._webout, + log: parsedSasjsServerLog + } + : res this.requestClient!.appendRequest(resObj, sasJob, config.debug) + if ( + this.serverType === ServerType.Sasjs && + res.result._webout.length < 1 + ) { + throw new JobExecutionError( + 0, + 'Job execution failed', + parsedSasjsServerLog + ) + } + let jsonResponse = res.result if (config.debug) { From 451d0906fae35724b4e2cbc7d85c1cece3cba841 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Fri, 10 Jun 2022 15:31:09 +0500 Subject: [PATCH 2/3] chore: update error message --- src/job-execution/WebJobExecutor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job-execution/WebJobExecutor.ts b/src/job-execution/WebJobExecutor.ts index dcd1feb..8555fa0 100644 --- a/src/job-execution/WebJobExecutor.ts +++ b/src/job-execution/WebJobExecutor.ts @@ -185,7 +185,7 @@ export class WebJobExecutor extends BaseJobExecutor { ) { throw new JobExecutionError( 0, - 'Job execution failed', + `No webout was returned by job ${program}. Server type is SASJS and the calling function is WebJobExecutor. Please check the SAS log for more info.`, parsedSasjsServerLog ) } From a3cc274ef12e2add40723564e0c7f1afc53e8101 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Fri, 10 Jun 2022 15:38:03 +0500 Subject: [PATCH 3/3] chore: no need to appendRequest from then block when there is jobExecutionError --- src/job-execution/WebJobExecutor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/job-execution/WebJobExecutor.ts b/src/job-execution/WebJobExecutor.ts index 8555fa0..a813794 100644 --- a/src/job-execution/WebJobExecutor.ts +++ b/src/job-execution/WebJobExecutor.ts @@ -177,8 +177,6 @@ export class WebJobExecutor extends BaseJobExecutor { } : res - this.requestClient!.appendRequest(resObj, sasJob, config.debug) - if ( this.serverType === ServerType.Sasjs && res.result._webout.length < 1 @@ -190,6 +188,8 @@ export class WebJobExecutor extends BaseJobExecutor { ) } + this.requestClient!.appendRequest(resObj, sasJob, config.debug) + let jsonResponse = res.result if (config.debug) {