1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-10 05:40:06 +00:00

fix(error): added error handling for http responses with status 401 and 403

This commit is contained in:
Yury Shkoda
2020-09-18 12:54:17 +03:00
parent 6fb9d11712
commit 6a055a4fc6
2 changed files with 35 additions and 14 deletions

View File

@@ -323,17 +323,14 @@ export class SASViyaApiClient {
{
headers
}
).catch((e) => {
console.error(e)
if (e && e.status === 404) {
).catch((err) => {
if (err && err.status === 404) {
throw new Error(
`The context '${contextName}' was not found on this server.`
)
}
throw new Error(
`An error occurred when fetching the context '${contextName}'.`
)
throw err
})
// An If-Match header with the value of the last ETag for the context
@@ -1388,12 +1385,8 @@ export class SASViyaApiClient {
const { result: contexts } = await this.request<{ items: Context[] }>(
`${this.serverUrl}/compute/contexts?filter=eq(name, "${contextName}")`,
{ headers }
).catch((e) => {
console.error(e)
throw new Error(
`An error occurred when fetching the context '${contextName}'.`
)
).catch((err) => {
throw err
})
if (!contexts || !(contexts.items && contexts.items.length)) {