Skip to content

Commit 5c87de5

Browse files
committed
feat: Add a isFetchError typeguard for FetchError (resolves #460)
1 parent bdfb507 commit 5c87de5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/error.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export class FetchError<T = any> extends Error implements IFetchError<T> {
1818
// Augment `FetchError` type to include `IFetchError` properties
1919
export interface FetchError<T = any> extends IFetchError<T> {}
2020

21+
export function isFetchError() {
22+
return (e: unknown): e is FetchError => e instanceof FetchError;
23+
}
24+
2125
export function createFetchError<T = any>(
2226
ctx: FetchContext<T>
2327
): IFetchError<T> {

0 commit comments

Comments
 (0)