@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.
@@ -1,3 +1,3 @@
1
1
  export declare class LoginRequiredError extends Error {
2
- constructor();
2
+ constructor(details?: any);
3
3
  }
package/package.json CHANGED
@@ -79,5 +79,5 @@
79
79
  "https": "1.0.0",
80
80
  "tough-cookie": "4.0.0"
81
81
  },
82
- "version": "3.7.10"
82
+ "version": "3.7.13"
83
83
  }
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
- let resString = res
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
- let errString = err
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
- if (response.status === 401) {
561
- throw new LoginRequiredError()
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
- super('Auth error: You must be logged in to access this resource')
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
  }
@@ -1,3 +1,3 @@
1
1
  export declare class LoginRequiredError extends Error {
2
- constructor();
2
+ constructor(details?: any);
3
3
  }