@unito/integration-sdk 1.4.2 → 1.4.3

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.
@@ -1366,7 +1366,7 @@ class Provider {
1366
1366
  case 'TimeoutError':
1367
1367
  throw this.handleError(408, 'Request timeout', options);
1368
1368
  }
1369
- throw this.handleError(500, `Unexpected error while calling the provider: name: "${error.name}" \n message: "${error.message}" \n stack: ${error.stack}`, options);
1369
+ throw this.handleError(500, `Unexpected error while calling the provider. ErrorName: "${error.name}" \n message: "${error.message}" \n stack: ${error.stack} \n cause: ${error.cause} \n causeStack: ${error.cause?.stack}`, options);
1370
1370
  }
1371
1371
  throw this.handleError(500, 'Unexpected error while calling the provider - this is not normal, investigate', options);
1372
1372
  }
@@ -267,7 +267,7 @@ export class Provider {
267
267
  case 'TimeoutError':
268
268
  throw this.handleError(408, 'Request timeout', options);
269
269
  }
270
- throw this.handleError(500, `Unexpected error while calling the provider: name: "${error.name}" \n message: "${error.message}" \n stack: ${error.stack}`, options);
270
+ throw this.handleError(500, `Unexpected error while calling the provider. ErrorName: "${error.name}" \n message: "${error.message}" \n stack: ${error.stack} \n cause: ${error.cause} \n causeStack: ${error.cause?.stack}`, options);
271
271
  }
272
272
  throw this.handleError(500, 'Unexpected error while calling the provider - this is not normal, investigate', options);
273
273
  }
@@ -553,7 +553,7 @@ describe('Provider', () => {
553
553
  });
554
554
  it('throws on unknown errors', async (context) => {
555
555
  context.mock.method(global, 'fetch', () => {
556
- throw new Error('foo');
556
+ throw new TypeError('foo', { cause: new Error('bar') });
557
557
  });
558
558
  let error;
559
559
  try {
@@ -567,10 +567,12 @@ describe('Provider', () => {
567
567
  error = e;
568
568
  }
569
569
  assert.ok(error instanceof HttpErrors.HttpError);
570
- assert.ok(error.message.startsWith('Unexpected error while calling the provider:'));
571
- assert.ok(error.message.includes('name: "Error"'));
570
+ assert.ok(error.message.startsWith('Unexpected error while calling the provider.'));
571
+ assert.ok(error.message.includes('ErrorName: "TypeError"'));
572
572
  assert.ok(error.message.includes('message: "foo"'));
573
573
  assert.ok(error.message.includes('stack:'));
574
+ assert.ok(error.message.includes('cause:'));
575
+ assert.ok(error.message.includes('causeStack:'));
574
576
  });
575
577
  it('throws on status 429', async (context) => {
576
578
  const response = new Response('response body', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unito/integration-sdk",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Integration SDK",
5
5
  "type": "module",
6
6
  "types": "dist/src/index.d.ts",
@@ -372,9 +372,10 @@ export class Provider {
372
372
  case 'TimeoutError':
373
373
  throw this.handleError(408, 'Request timeout', options);
374
374
  }
375
+
375
376
  throw this.handleError(
376
377
  500,
377
- `Unexpected error while calling the provider: name: "${error.name}" \n message: "${error.message}" \n stack: ${error.stack}`,
378
+ `Unexpected error while calling the provider. ErrorName: "${error.name}" \n message: "${error.message}" \n stack: ${error.stack} \n cause: ${error.cause} \n causeStack: ${(error.cause as Error)?.stack}`,
378
379
  options,
379
380
  );
380
381
  }
@@ -658,7 +658,7 @@ describe('Provider', () => {
658
658
 
659
659
  it('throws on unknown errors', async context => {
660
660
  context.mock.method(global, 'fetch', () => {
661
- throw new Error('foo');
661
+ throw new TypeError('foo', { cause: new Error('bar') });
662
662
  });
663
663
 
664
664
  let error;
@@ -674,10 +674,12 @@ describe('Provider', () => {
674
674
  }
675
675
 
676
676
  assert.ok(error instanceof HttpErrors.HttpError);
677
- assert.ok(error.message.startsWith('Unexpected error while calling the provider:'));
678
- assert.ok(error.message.includes('name: "Error"'));
677
+ assert.ok(error.message.startsWith('Unexpected error while calling the provider.'));
678
+ assert.ok(error.message.includes('ErrorName: "TypeError"'));
679
679
  assert.ok(error.message.includes('message: "foo"'));
680
680
  assert.ok(error.message.includes('stack:'));
681
+ assert.ok(error.message.includes('cause:'));
682
+ assert.ok(error.message.includes('causeStack:'));
681
683
  });
682
684
 
683
685
  it('throws on status 429', async context => {