CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-aggregate-error

Create an error from multiple errors

94

1.28x
Overview
Eval results
Files

task.mdevals/scenario-8/

Error Log Aggregator

Build a utility that collects and aggregates multiple errors from various sources, handling edge cases where errors may not have complete stack trace information.

Requirements

Create a function that aggregates errors into a single error object. The function should:

  • Accept an array of errors (Error objects, error-like objects, or strings)
  • Return a single error that represents all input errors combined
  • Handle errors that are missing stack trace properties
  • Handle errors with empty stack traces
  • Allow access to all individual errors after aggregation

Implementation

@generates

API

/**
 * Aggregates multiple errors into a single error object.
 *
 * @param {Array<Error|object|string>} errors - Array of errors to aggregate
 * @returns {Error} An aggregated error containing all input errors
 */
function aggregateErrors(errors) {
  // IMPLEMENTATION HERE
}

module.exports = { aggregateErrors };

Test Cases

  • When given an array containing an error with no stack property, it includes that error in the aggregated result without throwing @test
  • When given an array containing an error with an empty string stack, it handles it gracefully and includes it in the result @test
  • When given an array with a custom error class that has deleted its stack property, it includes the error in the aggregated result @test
  • The aggregated error allows iteration over all individual errors that were passed in @test

Dependencies { .dependencies }

aggregate-error { .dependency }

Provides error aggregation functionality with robust edge case handling.

Install with Tessl CLI

npx tessl i tessl/npm-aggregate-error

tile.json