@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.
package/package.json
CHANGED
|
@@ -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
|
}
|