1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

fix(job-execution): fetch log when webout is not available

This commit is contained in:
Krishna Acondy
2020-09-20 11:42:49 +01:00
parent a92a458cf1
commit 1be64798c5

View File

@@ -14,9 +14,10 @@ import {
Context,
Folder,
CsrfToken,
EditContextInput
EditContextInput,
ErrorResponse,
JobDefinition
} from './types'
import { JobDefinition } from './types/JobDefinition'
import { formatDataForRequest } from './utils/formatDataForRequest'
import { SessionManager } from './SessionManager'
@@ -540,9 +541,30 @@ export class SASViyaApiClient {
`${this.serverUrl}${resultLink}`,
{ headers },
'text'
).catch((e) => ({
result: JSON.stringify(e)
}))
).catch(async (e) => {
if (e && e.status === 404) {
if (logLink) {
log = await this.request<any>(
`${this.serverUrl}${logLink.href}/content?limit=10000`,
{
headers
}
).then((res: any) =>
res.result.items.map((i: any) => i.line).join('\n')
)
return Promise.reject(
new ErrorResponse('Job execution failed', {
status: 500,
body: log
})
)
}
}
return {
result: JSON.stringify(e)
}
})
}
await this.sessionManager.clearSession(executionSessionId, accessToken)