Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 101c357

Browse files
boris-petrovalexlafroscia
authored andcommitted
fix: is*Error type definitions
They should accept any type of AjaxError and not the specific type they check for as this doesn't make sense
1 parent fe518dc commit 101c357

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

addon/errors.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ export function isAjaxError(error: any): error is AjaxError {
8787
* Checks if the given status code or AjaxError object represents an
8888
* unauthorized request error
8989
*/
90-
export function isUnauthorizedError(
91-
error: UnauthorizedError | number
92-
): boolean {
90+
export function isUnauthorizedError(error: AjaxError | number): boolean {
9391
if (isAjaxError(error)) {
9492
return error instanceof UnauthorizedError;
9593
} else {
@@ -101,7 +99,7 @@ export function isUnauthorizedError(
10199
* Checks if the given status code or AjaxError object represents a forbidden
102100
* request error
103101
*/
104-
export function isForbiddenError(error: ForbiddenError | number): boolean {
102+
export function isForbiddenError(error: AjaxError | number): boolean {
105103
if (isAjaxError(error)) {
106104
return error instanceof ForbiddenError;
107105
} else {
@@ -113,7 +111,7 @@ export function isForbiddenError(error: ForbiddenError | number): boolean {
113111
* Checks if the given status code or AjaxError object represents an invalid
114112
* request error
115113
*/
116-
export function isInvalidError(error: InvalidError | number): boolean {
114+
export function isInvalidError(error: AjaxError | number): boolean {
117115
if (isAjaxError(error)) {
118116
return error instanceof InvalidError;
119117
} else {
@@ -125,7 +123,7 @@ export function isInvalidError(error: InvalidError | number): boolean {
125123
* Checks if the given status code or AjaxError object represents a bad request
126124
* error
127125
*/
128-
export function isBadRequestError(error: BadRequestError | number): boolean {
126+
export function isBadRequestError(error: AjaxError | number): boolean {
129127
if (isAjaxError(error)) {
130128
return error instanceof BadRequestError;
131129
} else {
@@ -137,7 +135,7 @@ export function isBadRequestError(error: BadRequestError | number): boolean {
137135
* Checks if the given status code or AjaxError object represents a "not found"
138136
* error
139137
*/
140-
export function isNotFoundError(error: NotFoundError | number): boolean {
138+
export function isNotFoundError(error: AjaxError | number): boolean {
141139
if (isAjaxError(error)) {
142140
return error instanceof NotFoundError;
143141
} else {
@@ -149,7 +147,7 @@ export function isNotFoundError(error: NotFoundError | number): boolean {
149147
* Checks if the given status code or AjaxError object represents a "gone"
150148
* error
151149
*/
152-
export function isGoneError(error: GoneError | number): boolean {
150+
export function isGoneError(error: AjaxError | number): boolean {
153151
if (isAjaxError(error)) {
154152
return error instanceof GoneError;
155153
} else {
@@ -168,7 +166,7 @@ export function isTimeoutError(error: any) {
168166
* Checks if the given status code or AjaxError object represents an
169167
* "abort" error
170168
*/
171-
export function isAbortError(error: AbortError | number): boolean {
169+
export function isAbortError(error: AjaxError | number): boolean {
172170
if (isAjaxError(error)) {
173171
return error instanceof AbortError;
174172
} else {
@@ -180,7 +178,7 @@ export function isAbortError(error: AbortError | number): boolean {
180178
* Checks if the given status code or AjaxError object represents a
181179
* conflict error
182180
*/
183-
export function isConflictError(error: ConflictError | number): boolean {
181+
export function isConflictError(error: AjaxError | number): boolean {
184182
if (isAjaxError(error)) {
185183
return error instanceof ConflictError;
186184
} else {
@@ -191,7 +189,7 @@ export function isConflictError(error: ConflictError | number): boolean {
191189
/**
192190
* Checks if the given status code or AjaxError object represents a server error
193191
*/
194-
export function isServerError(error: ServerError | number): boolean {
192+
export function isServerError(error: AjaxError | number): boolean {
195193
if (isAjaxError(error)) {
196194
return error instanceof ServerError;
197195
} else {

0 commit comments

Comments
 (0)