utilful 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,10 +32,16 @@ function isExpected(error, expectedErrors) {
32
32
  function formatCauseChain(error, message) {
33
33
  const causeLines = [];
34
34
  const seen = /* @__PURE__ */ new Set([error]);
35
+ let printedText = message;
35
36
  let current = error instanceof Error ? error.cause : void 0;
36
37
  while (current instanceof Error && !seen.has(current)) {
37
38
  seen.add(current);
38
- if (current.message !== message) causeLines.push(`Caused by: ${current.name || "Error"}: ${current.message}`);
39
+ const name = current.name || "Error";
40
+ if (!current.message) causeLines.push(`Caused by: ${name}`);
41
+ else if (!printedText.includes(current.message)) {
42
+ causeLines.push(`Caused by: ${name}: ${current.message}`);
43
+ printedText += `\n${current.message}`;
44
+ }
39
45
  current = current.cause;
40
46
  }
41
47
  return causeLines.join("\n");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilful",
3
3
  "type": "module",
4
- "version": "3.5.0",
4
+ "version": "3.5.1",
5
5
  "packageManager": "pnpm@11.25.0",
6
6
  "description": "A collection of TypeScript utilities",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",