@oclif/core 4.11.5 → 4.11.6

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.
@@ -4,5 +4,6 @@ type CLIErrorDisplayOptions = {
4
4
  name?: string | undefined;
5
5
  };
6
6
  export declare function applyPrettyPrintOptions(error: Error, options: PrettyPrintableError): PrettyPrintableError;
7
- export default function prettyPrint(error: Error & PrettyPrintableError & CLIErrorDisplayOptions): string | undefined;
7
+ type CombinedErrorType = Error & PrettyPrintableError & CLIErrorDisplayOptions;
8
+ export default function prettyPrint(error: CombinedErrorType): string | undefined;
8
9
  export {};
@@ -29,23 +29,39 @@ const formatSuggestions = (suggestions) => {
29
29
  const multiple = suggestions.map((suggestion) => `* ${suggestion}`).join('\n');
30
30
  return `${label}\n${(0, indent_string_1.default)(multiple, 2)}`;
31
31
  };
32
+ function isCombinedErrorType(obj) {
33
+ return Boolean(obj) && 'name' in obj && 'message' in obj;
34
+ }
32
35
  function prettyPrint(error) {
33
- if (settings_1.settings.debug) {
34
- return error.stack;
36
+ const prettyPrintedErrors = [];
37
+ let currentError = error;
38
+ let isDeep = false;
39
+ while (isCombinedErrorType(currentError)) {
40
+ if (settings_1.settings.debug && currentError.stack) {
41
+ prettyPrintedErrors.push(`${isDeep ? 'Caused by: ' : ''}${currentError.stack}`);
42
+ }
43
+ else {
44
+ const { bang, code, message, name: errorSuffix, ref, suggestions } = currentError;
45
+ // errorSuffix is pulled from the 'name' property on CLIError
46
+ // and is like either Error or Warning
47
+ const formattedHeader = message ? `${errorSuffix || 'Error'}: ${message}` : undefined;
48
+ const formattedCode = code ? `Code: ${code}` : undefined;
49
+ const formattedSuggestions = formatSuggestions(suggestions);
50
+ const formattedReference = ref ? `Reference: ${ref}` : undefined;
51
+ const formatted = [formattedHeader, formattedCode, formattedSuggestions, formattedReference]
52
+ .filter(Boolean)
53
+ .join('\n');
54
+ let output = `${isDeep ? 'Caused by: ' : ''}${formatted}`;
55
+ output = (0, wrap_ansi_1.default)(output, screen_1.errtermwidth - 6, { hard: true, trim: false });
56
+ if (!settings_1.settings.debug) {
57
+ output = (0, indent_string_1.default)(output, 3);
58
+ output = (0, indent_string_1.default)(output, 1, { includeEmptyLines: true, indent: bang || '' });
59
+ output = (0, indent_string_1.default)(output, 1);
60
+ }
61
+ prettyPrintedErrors.push(output);
62
+ }
63
+ isDeep = true;
64
+ currentError = currentError.cause ?? null;
35
65
  }
36
- const { bang, code, message, name: errorSuffix, ref, suggestions } = error;
37
- // errorSuffix is pulled from the 'name' property on CLIError
38
- // and is like either Error or Warning
39
- const formattedHeader = message ? `${errorSuffix || 'Error'}: ${message}` : undefined;
40
- const formattedCode = code ? `Code: ${code}` : undefined;
41
- const formattedSuggestions = formatSuggestions(suggestions);
42
- const formattedReference = ref ? `Reference: ${ref}` : undefined;
43
- const formatted = [formattedHeader, formattedCode, formattedSuggestions, formattedReference]
44
- .filter(Boolean)
45
- .join('\n');
46
- let output = (0, wrap_ansi_1.default)(formatted, screen_1.errtermwidth - 6, { hard: true, trim: false });
47
- output = (0, indent_string_1.default)(output, 3);
48
- output = (0, indent_string_1.default)(output, 1, { includeEmptyLines: true, indent: bang || '' });
49
- output = (0, indent_string_1.default)(output, 1);
50
- return output;
66
+ return prettyPrintedErrors.join('\n');
51
67
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "4.11.5",
4
+ "version": "4.11.6",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {