@sasjs/adapter 3.7.11 → 3.7.12

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.11"
82
+ "version": "3.7.12"
83
83
  }
@@ -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
  }