mol_jsx_lib 0.0.1159 → 0.0.1161

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/node.mjs CHANGED
@@ -193,17 +193,36 @@ var $;
193
193
  "use strict";
194
194
  var $;
195
195
  (function ($) {
196
+ function cause_serialize(cause) {
197
+ return JSON.stringify(cause, null, ' ')
198
+ .replace(/\(/, '<')
199
+ .replace(/\)/, ' >');
200
+ }
201
+ function frame_normalize(frame) {
202
+ return (typeof frame === 'string' ? frame : cause_serialize(frame))
203
+ .trim()
204
+ .replace(/at /gm, ' at ')
205
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
206
+ }
196
207
  class $mol_error_mix extends AggregateError {
197
208
  cause;
198
209
  name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
199
210
  constructor(message, cause = {}, ...errors) {
200
211
  super(errors, message, { cause });
201
212
  this.cause = cause;
202
- const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
213
+ const desc = Object.getOwnPropertyDescriptor(this, 'stack');
214
+ const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
203
215
  Object.defineProperty(this, 'stack', {
204
- get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
205
- .replace(/at /gm, ' at ')
206
- .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
216
+ get: () => stack_get() + '\n' + [
217
+ this.cause ?? 'no cause',
218
+ ...this.errors.flatMap(e => [
219
+ e.stack,
220
+ ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
221
+ ])
222
+ ].map(frame_normalize).join('\n')
223
+ });
224
+ Object.defineProperty(this, 'cause', {
225
+ get: () => cause
207
226
  });
208
227
  }
209
228
  static [Symbol.toPrimitive]() {
package/node.test.js CHANGED
@@ -184,17 +184,36 @@ var $;
184
184
  "use strict";
185
185
  var $;
186
186
  (function ($) {
187
+ function cause_serialize(cause) {
188
+ return JSON.stringify(cause, null, ' ')
189
+ .replace(/\(/, '<')
190
+ .replace(/\)/, ' >');
191
+ }
192
+ function frame_normalize(frame) {
193
+ return (typeof frame === 'string' ? frame : cause_serialize(frame))
194
+ .trim()
195
+ .replace(/at /gm, ' at ')
196
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
197
+ }
187
198
  class $mol_error_mix extends AggregateError {
188
199
  cause;
189
200
  name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
190
201
  constructor(message, cause = {}, ...errors) {
191
202
  super(errors, message, { cause });
192
203
  this.cause = cause;
193
- const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
204
+ const desc = Object.getOwnPropertyDescriptor(this, 'stack');
205
+ const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
194
206
  Object.defineProperty(this, 'stack', {
195
- get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
196
- .replace(/at /gm, ' at ')
197
- .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
207
+ get: () => stack_get() + '\n' + [
208
+ this.cause ?? 'no cause',
209
+ ...this.errors.flatMap(e => [
210
+ e.stack,
211
+ ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
212
+ ])
213
+ ].map(frame_normalize).join('\n')
214
+ });
215
+ Object.defineProperty(this, 'cause', {
216
+ get: () => cause
198
217
  });
199
218
  }
200
219
  static [Symbol.toPrimitive]() {