Skip to content

Commit

Permalink
refactor: use this to instantiate new instance of the same class
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Jul 23, 2024
1 parent 3ae2739 commit 5b6bb09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions packages/core/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
export class ReDotError extends Error {
static from<T>(error: T, message?: string): ReDotError {
return new ReDotError(message, { cause: error });
static from<T>(error: T, message?: string) {
return new this(message, { cause: error });
}
}

export class QueryError extends ReDotError {
static override from<T>(error: T, message?: string): QueryError {
return new QueryError(message, { cause: error });
}
}
export class QueryError extends ReDotError {}

export class MutationError extends ReDotError {
static override from<T>(error: T, message?: string): MutationError {
return new MutationError(message, { cause: error });
}
}
export class MutationError extends ReDotError {}
4 changes: 2 additions & 2 deletions packages/react/src/utils/jotai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class AtomFamilyError extends QueryError {
? Param
: unknown,
message?: string,
): AtomFamilyError {
return new AtomFamilyError(atomFamily, param, message, {
) {
return new this(atomFamily, param, message, {
cause: error,
});
}
Expand Down

0 comments on commit 5b6bb09

Please sign in to comment.