Skip to content

Commit

Permalink
fix: 不要な関数を除去
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Feb 24, 2025
1 parent 4a4cb10 commit 44afe46
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/helpers/errorHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { UnreachableError } from "@/type/utility";

/** 入力がnullかundefinedの場合エラーを投げ、それ以外の場合は入力をそのまま返す */
export const ensureNotNullish = <T>(
value: T | null | undefined,
Expand Down Expand Up @@ -40,13 +38,14 @@ export const errorToMessages = (
};

function flattenErrors(e: unknown): unknown[] {
const errors = [e];
if (e instanceof AggregateError) {
return [e, ...e.errors.flatMap(flattenErrors)];
errors.push(...e.errors.flatMap(flattenErrors));
}
if (e instanceof Error) {
return [e, ...(e.cause ? flattenErrors(e.cause) : [])];
if (e instanceof Error && e.cause) {
errors.push(...flattenErrors(e.cause));
}
return [e];
return errors;
}

function splitErrors(errors: unknown[]): {
Expand Down

0 comments on commit 44afe46

Please sign in to comment.