mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-09 13:30:04 +00:00
fix(sas9-support): throw error with invalid credentials
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
} from '../types/errors'
|
} from '../types/errors'
|
||||||
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
|
import { SAS9AuthError } from '../types/errors/SAS9AuthError'
|
||||||
|
|
||||||
export interface HttpClient {
|
export interface HttpClient {
|
||||||
get<T>(
|
get<T>(
|
||||||
@@ -470,6 +471,10 @@ export const throwIfError = (response: AxiosResponse) => {
|
|||||||
throw new AuthorizeError(response.data.message, authorizeRequestUrl)
|
throw new AuthorizeError(response.data.message, authorizeRequestUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.config?.url?.includes('sasAuthError')) {
|
||||||
|
throw new SAS9AuthError()
|
||||||
|
}
|
||||||
|
|
||||||
const error = parseError(response.data as string)
|
const error = parseError(response.data as string)
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
9
src/types/errors/SAS9AuthError.ts
Normal file
9
src/types/errors/SAS9AuthError.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export class SAS9AuthError extends Error {
|
||||||
|
constructor() {
|
||||||
|
super(
|
||||||
|
'The credentials you provided cannot be authenticated. Please provide a valid set of credentials.'
|
||||||
|
)
|
||||||
|
this.name = 'AuthorizeError'
|
||||||
|
Object.setPrototypeOf(this, SAS9AuthError.prototype)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user