INNER CODE UNIT · TypeScript
handlePromiseAllWithErrorsError
austin-starks/Promptimizer · src/utils/index.ts:84
export const handlePromiseAllWithErrorsError = (err: Error) => {
if (err instanceof PromiseAllWithErrorsError) {
for (const error of err.errors) {
console.error(error);
}
return err.successes;
}
throw err;
};
export async function promiseAllWithErrors<T>(
promises: Promise<T>[]
): Promise<T[]> {
const results = await Promise.allSettled(promises);
const fulfilled: T[] = [];
const errors: string[] = [];