diff --git a/src/request/RequestClient.ts b/src/request/RequestClient.ts index 991b7a3..62a144e 100644 --- a/src/request/RequestClient.ts +++ b/src/request/RequestClient.ts @@ -10,6 +10,7 @@ import { } from '../types/errors' import { parseWeboutResponse } from '../utils/parseWeboutResponse' import { prefixMessage } from '@sasjs/utils/error' +import { SAS9AuthError } from '../types/errors/SAS9AuthError' export interface HttpClient { get( @@ -470,6 +471,10 @@ export const throwIfError = (response: AxiosResponse) => { throw new AuthorizeError(response.data.message, authorizeRequestUrl) } + if (response.config?.url?.includes('sasAuthError')) { + throw new SAS9AuthError() + } + const error = parseError(response.data as string) if (error) { diff --git a/src/types/errors/SAS9AuthError.ts b/src/types/errors/SAS9AuthError.ts new file mode 100644 index 0000000..2e3ad00 --- /dev/null +++ b/src/types/errors/SAS9AuthError.ts @@ -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) + } +}