@sasjs/adapter 3.7.10 → 3.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/node/index.js +2 -2
- package/node/types/errors/LoginRequiredError.d.ts +1 -1
- package/package.json +1 -1
- package/src/SASjs.ts +3 -0
- package/src/job-execution/Sas9JobExecutor.ts +4 -16
- package/src/request/RequestClient.ts +12 -2
- package/src/types/errors/LoginRequiredError.ts +6 -2
- package/types/errors/LoginRequiredError.d.ts +1 -1
package/package.json
CHANGED
package/src/SASjs.ts
CHANGED
|
@@ -113,6 +113,9 @@ export default class SASjs {
|
|
|
113
113
|
debug?: boolean
|
|
114
114
|
) {
|
|
115
115
|
this.isMethodSupported('executeScriptSASViya', [ServerType.SasViya])
|
|
116
|
+
|
|
117
|
+
contextName = contextName || this.sasjsConfig.contextName
|
|
118
|
+
|
|
116
119
|
if (!contextName) {
|
|
117
120
|
throw new Error(
|
|
118
121
|
'Context name is undefined. Please set a `contextName` in your SASjs or override config.'
|
|
@@ -85,25 +85,13 @@ export class Sas9JobExecutor extends BaseJobExecutor {
|
|
|
85
85
|
}
|
|
86
86
|
)
|
|
87
87
|
.then((res: any) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (typeof res === 'object') {
|
|
91
|
-
resString = JSON.stringify(res)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
this.requestClient!.appendRequest(resString, sasJob, config.debug)
|
|
95
|
-
|
|
88
|
+
//appending response to requests array that will be used for requests history reference
|
|
89
|
+
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
|
96
90
|
return res
|
|
97
91
|
})
|
|
98
92
|
.catch((err: any) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (typeof err === 'object') {
|
|
102
|
-
errString = JSON.stringify(errString)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this.requestClient!.appendRequest(errString, sasJob, config.debug)
|
|
106
|
-
|
|
93
|
+
//appending error to requests array that will be used for requests history reference
|
|
94
|
+
this.requestClient!.appendRequest(err, sasJob, config.debug)
|
|
107
95
|
return err
|
|
108
96
|
})
|
|
109
97
|
}
|
|
@@ -557,8 +557,18 @@ export class RequestClient implements HttpClient {
|
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
export const throwIfError = (response: AxiosResponse) => {
|
|
560
|
-
|
|
561
|
-
|
|
560
|
+
switch (response.status) {
|
|
561
|
+
case 400:
|
|
562
|
+
if (typeof response.data === 'object') {
|
|
563
|
+
throw new LoginRequiredError(response.data)
|
|
564
|
+
}
|
|
565
|
+
break
|
|
566
|
+
case 401:
|
|
567
|
+
if (typeof response.data === 'object') {
|
|
568
|
+
throw new LoginRequiredError(response.data)
|
|
569
|
+
} else {
|
|
570
|
+
throw new LoginRequiredError()
|
|
571
|
+
}
|
|
562
572
|
}
|
|
563
573
|
|
|
564
574
|
if (response.data?.entityID?.includes('login')) {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export class LoginRequiredError extends Error {
|
|
2
|
-
constructor() {
|
|
3
|
-
|
|
2
|
+
constructor(details?: any) {
|
|
3
|
+
const message = details
|
|
4
|
+
? JSON.stringify(details, null, 2)
|
|
5
|
+
: 'You must be logged in to access this resource'
|
|
6
|
+
|
|
7
|
+
super(`Auth error: ${message}`)
|
|
4
8
|
this.name = 'LoginRequiredError'
|
|
5
9
|
Object.setPrototypeOf(this, LoginRequiredError.prototype)
|
|
6
10
|
}
|