Skip to content

Commit

Permalink
feat: Add a isFetchError typeguard for FetchError (resolves unjs#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugothms committed Nov 22, 2024
1 parent bdfb507 commit 5c87de5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class FetchError<T = any> extends Error implements IFetchError<T> {
// Augment `FetchError` type to include `IFetchError` properties
export interface FetchError<T = any> extends IFetchError<T> {}

export function isFetchError() {
return (e: unknown): e is FetchError => e instanceof FetchError;
}

export function createFetchError<T = any>(
ctx: FetchContext<T>
): IFetchError<T> {
Expand Down

0 comments on commit 5c87de5

Please sign in to comment.