Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(internal): deprecate makeAggregateError in favor of Aggregat… #9275

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/agoric-cli/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ export default async function installMain(progname, rawArgs, powers, opts) {
({ status }) => status !== 'fulfilled',
);
if (failures.length) {
if (typeof AggregateError !== 'function') {
throw failures[0].reason;
}
throw AggregateError(
failures.map(({ reason }) => reason),
'Failed to prune',
Expand Down
3 changes: 1 addition & 2 deletions packages/cosmic-swingset/src/export-kernel-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { fileURLToPath } from 'url';

import { makePromiseKit } from '@endo/promise-kit';
import { Fail, q } from '@agoric/assert';
import { makeAggregateError } from '@agoric/internal';
import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';
import { makeSwingStoreExporter } from '@agoric/swing-store';

Expand Down Expand Up @@ -239,7 +238,7 @@ export const initiateSwingStoreExport = (
.catch(err => errors.push(err));
}
if (errors.length) {
const error = makeAggregateError(errors, 'Errors while cleaning up');
const error = AggregateError(errors, 'Errors while cleaning up');
if (opErr) {
Object.defineProperty(error, 'cause', { value: opErr });
}
Expand Down
3 changes: 1 addition & 2 deletions packages/internal/src/node/fs-stream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createWriteStream } from 'node:fs';
import { open } from 'node:fs/promises';
import { makeAggregateError } from '../utils.js';

/**
* @param {import("fs").ReadStream | import("fs").WriteStream} stream
Expand Down Expand Up @@ -78,7 +77,7 @@ export const makeFsStreamWriter = async filePath => {
Promise.reject(
written.then(
() => err,
writtenError => makeAggregateError([err, writtenError]),
writtenError => AggregateError([err, writtenError]),
),
),
);
Expand Down
21 changes: 2 additions & 19 deletions packages/internal/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,6 @@
return measureSeconds;
};

/**
* @param {Error[]} errors
* @param {string} [message]
*/
export const makeAggregateError = (errors, message) => {
const err = Error(message);
Object.defineProperties(err, {
name: {
value: 'AggregateError',
},
errors: {
value: errors,
},
});
return err;
};

/**
* @template T
* @param {readonly (T | PromiseLike<T>)[]} items
Expand All @@ -101,7 +84,7 @@
} else if (errors.length === 1) {
throw errors[0];
} else {
throw makeAggregateError(errors);
throw AggregateError(errors);
}
});
};
Expand All @@ -119,7 +102,7 @@
finalizer(tryError)
.then(
() => tryError,
finalizeError => makeAggregateError([tryError, finalizeError]),
finalizeError => AggregateError([tryError, finalizeError]),
)
.then(error => Promise.reject(error)),
);
Expand Down Expand Up @@ -272,7 +255,7 @@
doneResult = { done: true, value: undefined };
},
);
resolvers.forEach(resolve => resolve(result));

Check warning on line 258 in packages/internal/src/utils.js

View workflow job for this annotation

GitHub Actions / lint-rest

Prefer for...of instead of Array.forEach
return pullNext();
};

Expand Down
3 changes: 1 addition & 2 deletions packages/telemetry/src/slog-sender-pipe-entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global process */
import '@endo/init';

import { makeAggregateError } from '@agoric/internal';
import anylogger from 'anylogger';
import { makeShutdown } from '@agoric/internal/src/node/shutdown.js';

Expand Down Expand Up @@ -75,7 +74,7 @@ const main = async () => {
sendErrors.unshift(actualFlushError);
}

return makeAggregateError(sendErrors.splice(0));
return AggregateError(sendErrors.splice(0));
};

process.on(
Expand Down
Loading