Skip to content

Commit

Permalink
Babel + Istanbul: Cannot count optional chaining operator coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Sep 1, 2020
1 parent cc07d1a commit 9371b22
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ class Base {
}

_checkStatusForError(statusCode, body) {

const {
error = {}
} = body ?? {error: {}};

const {
type,
message
} = error;

if (statusCode === 401) {
return new AirtableError(
'AUTHENTICATION_REQUIRED',
Expand All @@ -153,7 +163,7 @@ class Base {
} else if (statusCode === 404) {
return new AirtableError(
'NOT_FOUND',
body?.error?.message ?? 'Could not find what you are looking for',
message ?? 'Could not find what you are looking for',
statusCode
);
} else if (statusCode === 413) {
Expand All @@ -164,8 +174,8 @@ class Base {
);
} else if (statusCode === 422) {
return new AirtableError(
body?.error?.type ?? 'UNPROCESSABLE_ENTITY',
body?.error?.message ?? 'The operation cannot be processed',
type ?? 'UNPROCESSABLE_ENTITY',
message ?? 'The operation cannot be processed',
statusCode
);
} else if (statusCode === 429) {
Expand All @@ -188,8 +198,8 @@ class Base {
);
} else if (statusCode >= 400) {
return new AirtableError(
body?.error?.type ?? 'UNEXPECTED_ERROR',
body?.error?.message ?? 'An unexpected error occurred',
type ?? 'UNEXPECTED_ERROR',
message ?? 'An unexpected error occurred',
statusCode
);
} else {
Expand Down

0 comments on commit 9371b22

Please sign in to comment.