Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deploy): handle SAS9 execution error gracefully #1065

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import os from 'os'
import SASjs from '@sasjs/adapter/node'
import SASjs, { JobExecutionError } from '@sasjs/adapter/node'
import { getAuthConfig, getStreamConfig } from '../../utils/config'
import { displaySasjsRunnerError, executeShellScript } from '../../utils/utils'
import {
Expand Down Expand Up @@ -252,16 +252,24 @@ async function deployToSas9(
})
const executionResult = await sasjs
.executeScriptSAS9(linesToExecute, username, password)
.catch((err) => {
process.logger?.log(formatErrorString(err))
.catch(async (err) => {
if (err && err.errorCode === 404) {
displaySasjsRunnerError(username)
} else if (err instanceof JobExecutionError) {
process.logger?.error('Deployment completed with errors.')
const errorLogPath = path.join(
logFilePath || process.cwd(),
`${path.basename(deployScript).replace('.sas', '')}.log`
)
await createFile(errorLogPath, err.result)
process.logger?.info(`Error log is available at ${errorLogPath}`)
throw new Error()
} else {
process.logger?.error(formatErrorString(err))
}
})

if (!executionResult) {
process.logger?.error('Error getting execution log')
} else if (logFilePath) {
if (executionResult && logFilePath) {
await createFile(
path.join(
logFilePath,
Expand Down