From 111a48f983c5e7b63bb77b9b626ec25607c2612c Mon Sep 17 00:00:00 2001 From: Umar Ahmed Date: Wed, 27 Oct 2021 10:50:01 -0400 Subject: [PATCH] feat: add isFetchError type guard (#41) --- src/errors.ts | 7 +++++++ src/index.ts | 1 + 2 files changed, 8 insertions(+) create mode 100644 src/errors.ts diff --git a/src/errors.ts b/src/errors.ts new file mode 100644 index 0000000..a9ba45a --- /dev/null +++ b/src/errors.ts @@ -0,0 +1,7 @@ +import { FetchError } from './lib/fetch-error'; + +export function isFetchError(error: any): error is FetchError { + return error instanceof FetchError; +} + +export { FetchError }; diff --git a/src/index.ts b/src/index.ts index dcf78c2..e924eef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ // NOTE: do NOT export `Form` here. Next.js can't properly tree shake the client // bundle if there are client & server imports in a single import statement. +export * from './errors'; export * from './handle'; export * from './responses';