@sasjs/adapter 3.7.13 → 3.7.14

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.
@@ -14,6 +14,6 @@ export declare class Sas9JobExecutor extends BaseJobExecutor {
14
14
  private requestClient;
15
15
  private sas9RequestClient;
16
16
  constructor(serverUrl: string, serverType: ServerType, jobsPath: string, requestClient: RequestClient, httpsAgentOptions?: https.AgentOptions);
17
- execute(sasJob: string, data: any, config: any): Promise<any>;
17
+ execute(sasJob: string, data: any, config: any): Promise<unknown>;
18
18
  private getRequestParams;
19
19
  }
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.13"
82
+ "version": "3.7.14"
83
83
  }
@@ -74,26 +74,32 @@ export class Sas9JobExecutor extends BaseJobExecutor {
74
74
  ? 'multipart/form-data; boundary=' + (formData as any)._boundary
75
75
  : 'text/plain'
76
76
 
77
- return await this.sas9RequestClient!.post(
78
- apiUrl,
79
- formData,
80
- undefined,
81
- contentType,
82
- {
77
+ const requestPromise = new Promise((resolve, reject) =>
78
+ this.sas9RequestClient!.post(apiUrl, formData, undefined, contentType, {
83
79
  Accept: '*/*',
84
80
  Connection: 'Keep-Alive'
85
- }
86
- )
87
- .then((res: any) => {
88
- //appending response to requests array that will be used for requests history reference
89
- this.requestClient!.appendRequest(res, sasJob, config.debug)
90
- return res
91
- })
92
- .catch((err: any) => {
93
- //appending error to requests array that will be used for requests history reference
94
- this.requestClient!.appendRequest(err, sasJob, config.debug)
95
- return err
96
81
  })
82
+ .then((res: any) => {
83
+ // appending response to requests array that will be used for requests history reference
84
+ this.requestClient!.appendRequest(res, sasJob, config.debug)
85
+ resolve(res)
86
+ })
87
+ .catch((err: any) => {
88
+ // by default error string is equal to actual error object
89
+ let errString = err
90
+
91
+ // if error object contains non empty result attribute, set result to errString
92
+ if (err.result && err.result !== '') errString = err.result
93
+ // if there's no result but error message, set error message to errString
94
+ else if (err.message) errString = err.message
95
+
96
+ // appending error to requests array that will be used for requests history reference
97
+ this.requestClient!.appendRequest(errString, sasJob, config.debug)
98
+ reject(new ErrorResponse(err?.message, err))
99
+ })
100
+ )
101
+
102
+ return requestPromise
97
103
  }
98
104
 
99
105
  private getRequestParams(config: any): any {