Skip to content

Commit

Permalink
feat(ses): add COMPARTMENT_LOAD_ERRORS env option to print verbose ou…
Browse files Browse the repository at this point in the history
…tput for module loading errors
  • Loading branch information
naugtur committed Apr 30, 2024
1 parent e3248fa commit eca5f23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/ses/src/commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const { prototype: weakmapPrototype } = WeakMap;
export const { prototype: weaksetPrototype } = WeakSet;
export const { prototype: functionPrototype } = Function;
export const { prototype: promisePrototype } = Promise;
// eslint-disable-next-line no-empty-function
// eslint-disable-next-line no-empty-function, func-names
export const { prototype: iteratorPrototype } = getPrototypeOf(function* () {});

export const typedArrayPrototype = getPrototypeOf(Uint8Array.prototype);
Expand Down
10 changes: 5 additions & 5 deletions packages/ses/src/module-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// module's "imports" with the more specific "resolvedImports" as inferred from
// the particular compartment's "resolveHook".

import { getEnvironmentOption as getenv } from '@endo/env-options';
import {
ReferenceError,
TypeError,
Expand Down Expand Up @@ -362,14 +363,15 @@ function asyncOverseer() {
* @param {object} options
* @param {Array<Error>} options.errors
* @param {string} options.errorPrefix
* @param {boolean} [options.debug]
*/
function throwAggregateError({ errors, errorPrefix, debug = false }) {
function throwAggregateError({ errors, errorPrefix }) {
// Throw an aggregate error if there were any errors.
if (errors.length > 0) {
const verbose =
getenv('COMPARTMENT_LOAD_ERRORS', '', ['verbose']) === 'verbose';
throw TypeError(
`${errorPrefix} (${errors.length} underlying failures: ${arrayJoin(
arrayMap(errors, error => (debug ? error.stack : error.message)),
arrayMap(errors, error => error.message + (verbose ? error.stack : '')),
', ',
)}`,
);
Expand Down Expand Up @@ -420,7 +422,6 @@ export const load = async (
errorPrefix: `Failed to load ${q(moduleSpecifier)} in compartment ${q(
compartmentName,
)}`,
debug: true,
});
};

Expand Down Expand Up @@ -471,6 +472,5 @@ export const loadNow = (
errorPrefix: `Failed to load ${q(moduleSpecifier)} in compartment ${q(
compartmentName,
)}`,
debug: true,
});
};

0 comments on commit eca5f23

Please sign in to comment.