@twin.org/core 0.0.1-next.59 → 0.0.1-next.60

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.
@@ -709,7 +709,7 @@ class BaseError extends Error {
709
709
  */
710
710
  static flatten(err) {
711
711
  const flattened = [];
712
- let e = BaseError.fromError(err).toJsonObject();
712
+ let e = BaseError.fromError(err).toJsonObject(true);
713
713
  while (e) {
714
714
  const inner = e.inner;
715
715
  e.inner = undefined;
@@ -3132,10 +3132,23 @@ class ErrorHelper {
3132
3132
  /**
3133
3133
  * Format Errors and returns just their messages.
3134
3134
  * @param error The error to format.
3135
+ * @param includeDetails Whether to include error details, defaults to false.
3135
3136
  * @returns The error formatted including any inner errors.
3136
3137
  */
3137
- static formatErrors(error) {
3138
- return ErrorHelper.localizeErrors(error).map(e => e.message);
3138
+ static formatErrors(error, includeDetails) {
3139
+ const localizedErrors = ErrorHelper.localizeErrors(error);
3140
+ if (includeDetails ?? false) {
3141
+ const output = [];
3142
+ for (const err of localizedErrors) {
3143
+ let detailedError = err.message;
3144
+ if (Is.stringValue(err.stack)) {
3145
+ detailedError += `\n${err.stack}`;
3146
+ }
3147
+ output.push(detailedError);
3148
+ }
3149
+ return output;
3150
+ }
3151
+ return localizedErrors.map(e => e.message);
3139
3152
  }
3140
3153
  /**
3141
3154
  * Localize the content of an error and any inner errors.
@@ -707,7 +707,7 @@ class BaseError extends Error {
707
707
  */
708
708
  static flatten(err) {
709
709
  const flattened = [];
710
- let e = BaseError.fromError(err).toJsonObject();
710
+ let e = BaseError.fromError(err).toJsonObject(true);
711
711
  while (e) {
712
712
  const inner = e.inner;
713
713
  e.inner = undefined;
@@ -3130,10 +3130,23 @@ class ErrorHelper {
3130
3130
  /**
3131
3131
  * Format Errors and returns just their messages.
3132
3132
  * @param error The error to format.
3133
+ * @param includeDetails Whether to include error details, defaults to false.
3133
3134
  * @returns The error formatted including any inner errors.
3134
3135
  */
3135
- static formatErrors(error) {
3136
- return ErrorHelper.localizeErrors(error).map(e => e.message);
3136
+ static formatErrors(error, includeDetails) {
3137
+ const localizedErrors = ErrorHelper.localizeErrors(error);
3138
+ if (includeDetails ?? false) {
3139
+ const output = [];
3140
+ for (const err of localizedErrors) {
3141
+ let detailedError = err.message;
3142
+ if (Is.stringValue(err.stack)) {
3143
+ detailedError += `\n${err.stack}`;
3144
+ }
3145
+ output.push(detailedError);
3146
+ }
3147
+ return output;
3148
+ }
3149
+ return localizedErrors.map(e => e.message);
3137
3150
  }
3138
3151
  /**
3139
3152
  * Localize the content of an error and any inner errors.
@@ -6,9 +6,10 @@ export declare class ErrorHelper {
6
6
  /**
7
7
  * Format Errors and returns just their messages.
8
8
  * @param error The error to format.
9
+ * @param includeDetails Whether to include error details, defaults to false.
9
10
  * @returns The error formatted including any inner errors.
10
11
  */
11
- static formatErrors(error: unknown): string[];
12
+ static formatErrors(error: unknown, includeDetails?: boolean): string[];
12
13
  /**
13
14
  * Localize the content of an error and any inner errors.
14
15
  * @param error The error to format.
package/docs/changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @twin.org/core - Changelog
2
2
 
3
+ ## [0.0.1-next.60](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.59...core-v0.0.1-next.60) (2025-06-17)
4
+
5
+
6
+ ### Features
7
+
8
+ * improve error display in CLI ([94b6ca8](https://github.com/twinfoundation/framework/commit/94b6ca8bdcfe3ca7671c4095b436ea7bddaae98e))
9
+
3
10
  ## [0.0.1-next.59](https://github.com/twinfoundation/framework/compare/core-v0.0.1-next.58...core-v0.0.1-next.59) (2025-06-17)
4
11
 
5
12
 
@@ -16,7 +16,7 @@ Error helper functions.
16
16
 
17
17
  ### formatErrors()
18
18
 
19
- > `static` **formatErrors**(`error`): `string`[]
19
+ > `static` **formatErrors**(`error`, `includeDetails?`): `string`[]
20
20
 
21
21
  Format Errors and returns just their messages.
22
22
 
@@ -28,6 +28,12 @@ Format Errors and returns just their messages.
28
28
 
29
29
  The error to format.
30
30
 
31
+ ##### includeDetails?
32
+
33
+ `boolean`
34
+
35
+ Whether to include error details, defaults to false.
36
+
31
37
  #### Returns
32
38
 
33
39
  `string`[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/core",
3
- "version": "0.0.1-next.59",
3
+ "version": "0.0.1-next.60",
4
4
  "description": "Helper methods/classes for data type checking/validation/guarding/error handling",
5
5
  "repository": {
6
6
  "type": "git",