mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-18 17:40:06 +00:00
fix(request): handled error case for sas9 server
This commit is contained in:
@@ -499,16 +499,19 @@ export const throwIfError = (response: AxiosResponse) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parseError = (data: string) => {
|
const parseError = (data: string) => {
|
||||||
|
if (!data) return null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const responseJson = JSON.parse(data?.replace(/[\n\r]/g, ' '))
|
const responseJson = JSON.parse(data?.replace(/[\n\r]/g, ' '))
|
||||||
return responseJson.errorCode && responseJson.message
|
if (responseJson.errorCode && responseJson.message) {
|
||||||
? new JobExecutionError(
|
return new JobExecutionError(
|
||||||
responseJson.errorCode,
|
responseJson.errorCode,
|
||||||
responseJson.message,
|
responseJson.message,
|
||||||
data?.replace(/[\n\r]/g, ' ')
|
data?.replace(/[\n\r]/g, ' ')
|
||||||
)
|
)
|
||||||
: null
|
}
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const hasError = data?.includes('{"errorCode')
|
const hasError = data?.includes('{"errorCode')
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
@@ -522,8 +525,9 @@ const parseError = (data: string) => {
|
|||||||
data?.replace(/[\n\r]/g, '\n')
|
data?.replace(/[\n\r]/g, '\n')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const hasError = !!data?.match(/stored process not found: /i)
|
const hasError = !!data?.match(/stored process not found: /i)
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
@@ -534,11 +538,21 @@ const parseError = (data: string) => {
|
|||||||
return new JobExecutionError(404, message, '')
|
return new JobExecutionError(404, message, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const hasError =
|
||||||
|
!!data?.match(/Stored Process Error/i) &&
|
||||||
|
!!data?.match(/This request completed with errors./i)
|
||||||
|
if (hasError) {
|
||||||
|
const parts = data.split('<h2>SAS Log</h2>')
|
||||||
|
if (parts.length > 1) {
|
||||||
|
const log = parts[1].split('<pre>')[1].split('</pre>')[0]
|
||||||
|
const message = `This request completed with errors.`
|
||||||
|
return new JobExecutionError(404, message, log)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
|
||||||
} catch (_) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user