@prairielearn/error 3.0.10 → 3.0.12

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @prairielearn/error
2
2
 
3
+ ## 3.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 00945c2: Deprecate `formatErrorStackSafe` in favor of structured error logging.
8
+
9
+ ## 3.0.11
10
+
11
+ ### Patch Changes
12
+
13
+ - df28e68: Bump dependencies
14
+
3
15
  ## 3.0.10
4
16
 
5
17
  ### Patch Changes
package/dist/format.d.ts CHANGED
@@ -8,6 +8,8 @@ export declare function formatErrorStack(err: any, depth?: number, prefix?: stri
8
8
  * of an unexpected error object. We'll use the original function if it works,
9
9
  * but if it fails for any reason, we'll just return the plain stack, whatever
10
10
  * it might be.
11
+ *
12
+ * @deprecated Pass errors directly to `@prairielearn/logger` instead.
11
13
  */
12
14
  export declare function formatErrorStackSafe(err: any): string;
13
15
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,SAAI,EAAE,MAAM,SAAK,GAAG,MAAM,CAuBzE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAMrD","sourcesContent":["function indentString(stack: string, depth: number) {\n if (depth === 0) return stack;\n\n const indent = ' '.repeat(depth);\n return stack\n .split('\\n')\n .map((line) => (indent + line).trimEnd())\n .join('\\n');\n}\n\n/**\n * Recursively formats an error into a string. Correctly handles both the\n * `.cause` property and `AggregateError` instances.\n */\nexport function formatErrorStack(err: any, depth = 0, prefix = ''): string {\n // This will handle both circular references and unnecessarily deep chains.\n if (depth > 10) return '...';\n\n let stack = indentString(prefix + err.stack, depth);\n\n if (err.cause) {\n stack += `\\n\\n${formatErrorStack(err.cause, depth + 1, 'Cause: ')}`;\n }\n\n if (err instanceof AggregateError) {\n const indent = ' '.repeat(depth + 1);\n stack += `\\n\\n${indent}Errors: [\\n`;\n\n err.errors.forEach((error, i) => {\n stack += formatErrorStack(error, depth + 2);\n if (i < err.errors.length - 1) stack += '\\n\\n';\n });\n\n stack += `\\n${indent}]`;\n }\n\n return stack;\n}\n\n/**\n * This is a version of {@link formatErrorStack} that won't error in the case\n * of an unexpected error object. We'll use the original function if it works,\n * but if it fails for any reason, we'll just return the plain stack, whatever\n * it might be.\n */\nexport function formatErrorStackSafe(err: any): string {\n try {\n return formatErrorStack(err);\n } catch {\n return err.stack;\n }\n}\n"]}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,SAAI,EAAE,MAAM,SAAK,GAAG,MAAM,CAuBzE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAMrD","sourcesContent":["function indentString(stack: string, depth: number) {\n if (depth === 0) return stack;\n\n const indent = ' '.repeat(depth);\n return stack\n .split('\\n')\n .map((line) => (indent + line).trimEnd())\n .join('\\n');\n}\n\n/**\n * Recursively formats an error into a string. Correctly handles both the\n * `.cause` property and `AggregateError` instances.\n */\nexport function formatErrorStack(err: any, depth = 0, prefix = ''): string {\n // This will handle both circular references and unnecessarily deep chains.\n if (depth > 10) return '...';\n\n let stack = indentString(prefix + err.stack, depth);\n\n if (err.cause) {\n stack += `\\n\\n${formatErrorStack(err.cause, depth + 1, 'Cause: ')}`;\n }\n\n if (err instanceof AggregateError) {\n const indent = ' '.repeat(depth + 1);\n stack += `\\n\\n${indent}Errors: [\\n`;\n\n err.errors.forEach((error, i) => {\n stack += formatErrorStack(error, depth + 2);\n if (i < err.errors.length - 1) stack += '\\n\\n';\n });\n\n stack += `\\n${indent}]`;\n }\n\n return stack;\n}\n\n/**\n * This is a version of {@link formatErrorStack} that won't error in the case\n * of an unexpected error object. We'll use the original function if it works,\n * but if it fails for any reason, we'll just return the plain stack, whatever\n * it might be.\n *\n * @deprecated Pass errors directly to `@prairielearn/logger` instead.\n */\nexport function formatErrorStackSafe(err: any): string {\n try {\n return formatErrorStack(err);\n } catch {\n return err.stack;\n }\n}\n"]}
package/dist/format.js CHANGED
@@ -36,6 +36,8 @@ export function formatErrorStack(err, depth = 0, prefix = '') {
36
36
  * of an unexpected error object. We'll use the original function if it works,
37
37
  * but if it fails for any reason, we'll just return the plain stack, whatever
38
38
  * it might be.
39
+ *
40
+ * @deprecated Pass errors directly to `@prairielearn/logger` instead.
39
41
  */
40
42
  export function formatErrorStackSafe(err) {
41
43
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,CAAC,KAAa,EAAE,KAAa;IAChD,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE9B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,KAAK;SACT,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,EAAE;IAC/D,2EAA2E;IAC3E,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,KAAK,CAAC;IAE7B,IAAI,KAAK,GAAG,YAAY,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEpD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,IAAI,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;IACtE,CAAC;IAED,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,KAAK,IAAI,OAAO,MAAM,aAAa,CAAC;QAEpC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,KAAK,IAAI,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;gBAAE,KAAK,IAAI,MAAM,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,KAAK,IAAI,KAAK,MAAM,GAAG,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC3C,IAAI,CAAC;QACH,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["function indentString(stack: string, depth: number) {\n if (depth === 0) return stack;\n\n const indent = ' '.repeat(depth);\n return stack\n .split('\\n')\n .map((line) => (indent + line).trimEnd())\n .join('\\n');\n}\n\n/**\n * Recursively formats an error into a string. Correctly handles both the\n * `.cause` property and `AggregateError` instances.\n */\nexport function formatErrorStack(err: any, depth = 0, prefix = ''): string {\n // This will handle both circular references and unnecessarily deep chains.\n if (depth > 10) return '...';\n\n let stack = indentString(prefix + err.stack, depth);\n\n if (err.cause) {\n stack += `\\n\\n${formatErrorStack(err.cause, depth + 1, 'Cause: ')}`;\n }\n\n if (err instanceof AggregateError) {\n const indent = ' '.repeat(depth + 1);\n stack += `\\n\\n${indent}Errors: [\\n`;\n\n err.errors.forEach((error, i) => {\n stack += formatErrorStack(error, depth + 2);\n if (i < err.errors.length - 1) stack += '\\n\\n';\n });\n\n stack += `\\n${indent}]`;\n }\n\n return stack;\n}\n\n/**\n * This is a version of {@link formatErrorStack} that won't error in the case\n * of an unexpected error object. We'll use the original function if it works,\n * but if it fails for any reason, we'll just return the plain stack, whatever\n * it might be.\n */\nexport function formatErrorStackSafe(err: any): string {\n try {\n return formatErrorStack(err);\n } catch {\n return err.stack;\n }\n}\n"]}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,SAAS,YAAY,CAAC,KAAa,EAAE,KAAa;IAChD,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE9B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,KAAK;SACT,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,EAAE;IAC/D,2EAA2E;IAC3E,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,KAAK,CAAC;IAE7B,IAAI,KAAK,GAAG,YAAY,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEpD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,IAAI,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;IACtE,CAAC;IAED,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,KAAK,IAAI,OAAO,MAAM,aAAa,CAAC;QAEpC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,KAAK,IAAI,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;gBAAE,KAAK,IAAI,MAAM,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,KAAK,IAAI,KAAK,MAAM,GAAG,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC3C,IAAI,CAAC;QACH,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["function indentString(stack: string, depth: number) {\n if (depth === 0) return stack;\n\n const indent = ' '.repeat(depth);\n return stack\n .split('\\n')\n .map((line) => (indent + line).trimEnd())\n .join('\\n');\n}\n\n/**\n * Recursively formats an error into a string. Correctly handles both the\n * `.cause` property and `AggregateError` instances.\n */\nexport function formatErrorStack(err: any, depth = 0, prefix = ''): string {\n // This will handle both circular references and unnecessarily deep chains.\n if (depth > 10) return '...';\n\n let stack = indentString(prefix + err.stack, depth);\n\n if (err.cause) {\n stack += `\\n\\n${formatErrorStack(err.cause, depth + 1, 'Cause: ')}`;\n }\n\n if (err instanceof AggregateError) {\n const indent = ' '.repeat(depth + 1);\n stack += `\\n\\n${indent}Errors: [\\n`;\n\n err.errors.forEach((error, i) => {\n stack += formatErrorStack(error, depth + 2);\n if (i < err.errors.length - 1) stack += '\\n\\n';\n });\n\n stack += `\\n${indent}]`;\n }\n\n return stack;\n}\n\n/**\n * This is a version of {@link formatErrorStack} that won't error in the case\n * of an unexpected error object. We'll use the original function if it works,\n * but if it fails for any reason, we'll just return the plain stack, whatever\n * it might be.\n *\n * @deprecated Pass errors directly to `@prairielearn/logger` instead.\n */\nexport function formatErrorStackSafe(err: any): string {\n try {\n return formatErrorStack(err);\n } catch {\n return err.stack;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prairielearn/error",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,15 +12,15 @@
12
12
  },
13
13
  "main": "./dist/index.js",
14
14
  "dependencies": {
15
- "es-toolkit": "^1.49.0"
15
+ "es-toolkit": "^1.50.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/node": "^24.13.2",
18
+ "@types/node": "^24.13.3",
19
19
  "@typescript/native-preview": "beta",
20
- "@vitest/coverage-v8": "^4.1.9",
21
- "vitest": "^4.1.9",
22
- "@prairielearn/tsconfig": "^2.1.0",
23
- "@prairielearn/html": "^5.0.7"
20
+ "@vitest/coverage-v8": "^4.1.10",
21
+ "vitest": "^4.1.10",
22
+ "@prairielearn/html": "^5.0.8",
23
+ "@prairielearn/tsconfig": "^2.1.0"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsgo",
package/src/format.ts CHANGED
@@ -42,6 +42,8 @@ export function formatErrorStack(err: any, depth = 0, prefix = ''): string {
42
42
  * of an unexpected error object. We'll use the original function if it works,
43
43
  * but if it fails for any reason, we'll just return the plain stack, whatever
44
44
  * it might be.
45
+ *
46
+ * @deprecated Pass errors directly to `@prairielearn/logger` instead.
45
47
  */
46
48
  export function formatErrorStackSafe(err: any): string {
47
49
  try {
@@ -1 +0,0 @@
1
- $ tsgo