mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-10 05:40:06 +00:00
fix: log capture if job fails, test framework update, added test for log capture
This commit is contained in:
@@ -303,22 +303,8 @@ export class SASViyaApiClient {
|
||||
|
||||
let jobResult, log;
|
||||
|
||||
if (jobStatus === "failed" || jobStatus === "error") {
|
||||
return Promise.reject(currentJob.error);
|
||||
}
|
||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
||||
const logLink = currentJob.links.find((l) => l.rel === "log");
|
||||
|
||||
if (resultLink) {
|
||||
jobResult = await this.request<any>(
|
||||
`${this.serverUrl}${resultLink}`,
|
||||
{ headers },
|
||||
"text"
|
||||
).catch((e) => ({
|
||||
result: JSON.stringify(e),
|
||||
}));
|
||||
}
|
||||
|
||||
if (true && logLink) {
|
||||
log = await this.request<any>(
|
||||
`${this.serverUrl}${logLink.href}/content?limit=10000`,
|
||||
@@ -328,6 +314,21 @@ export class SASViyaApiClient {
|
||||
).then((res: any) => res.result.items.map((i: any) => i.line).join("\n"));
|
||||
}
|
||||
|
||||
if (jobStatus === "failed" || jobStatus === "error") {
|
||||
return Promise.reject({error: currentJob.error, log: log});
|
||||
}
|
||||
const resultLink = `/compute/sessions/${executionSessionId}/filerefs/_webout/content`;
|
||||
|
||||
if (resultLink) {
|
||||
jobResult = await this.request<any>(
|
||||
`${this.serverUrl}${resultLink}`,
|
||||
{ headers },
|
||||
"text"
|
||||
).catch((e) => ({
|
||||
result: JSON.stringify(e),
|
||||
}));
|
||||
}
|
||||
|
||||
await this.sessionManager.clearSession(executionSessionId, accessToken);
|
||||
|
||||
return { result: jobResult?.result, log };
|
||||
|
||||
Reference in New Issue
Block a user