@takeshape/errors 11.73.0 → 11.76.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/errors",
3
- "version": "11.73.0",
3
+ "version": "11.76.0",
4
4
  "description": "Custom error objects.",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "node": ">=20"
31
31
  },
32
32
  "scripts": {
33
- "build": "tsc --build tsconfig.build.json",
33
+ "build": "tsc --project tsconfig.build.json",
34
34
  "prebuild:ci": "pnpm clean",
35
35
  "build:ci": "pnpm build --noCheck",
36
36
  "clean": "del-cli dist coverage *.tsbuildinfo",
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { BadRequestError } from "../bad-request.js";
3
- test('BadRequestError provides an appropriate statusCode and validation method', () => {
4
- const message = 'is broken';
5
- const data = { validation: 'nah' };
6
- const error = new BadRequestError(message, { validation: 'nah' });
7
- expect(error.message).toEqual(message);
8
- expect(error.statusCode).toEqual(400);
9
- expect(error.validation).toEqual(data.validation);
10
- expect(error.validationMessages).toEqual(data.validation);
11
- expect(error.reportToSentry).toEqual(false);
12
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { BaseError } from "../base-error.js";
3
- class MockError extends BaseError {
4
- static code = 'MockError';
5
- static statusCode = 666;
6
- extensions = {
7
- http: { status: MockError.statusCode }
8
- };
9
- constructor(message = 'sign of the beast') {
10
- super(message);
11
- }
12
- }
13
- test('BaseError supports a code, status code, name, and default message when extended', () => {
14
- const error = new MockError();
15
- expect(error.name).toEqual('MockError');
16
- expect(error.message).toEqual('sign of the beast');
17
- expect(error.reportToSentry).toEqual(false);
18
- expect(error.statusCode).toEqual(666);
19
- expect(error.extensions.http.status).toEqual(666);
20
- });
21
- test('BaseError supports overriding a message when extended', () => {
22
- const message = 'mock message';
23
- const error = new MockError(message);
24
- expect(error.reportToSentry).toEqual(false);
25
- expect(error.unmaskError).toEqual(true);
26
- expect(error.message).toEqual(message);
27
- });
28
- test('BaseError supports settings reportToSentry in options', () => {
29
- const error = new BaseError('mock message', { reportToSentry: true });
30
- expect(error.reportToSentry).toEqual(true);
31
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { ServiceProviderError } from "../service-provider.js";
3
- test('ServiceProviderError provides an appropriate statusCode and validation method', () => {
4
- const message = 'is broken';
5
- const error = new ServiceProviderError(message);
6
- expect(error.message).toEqual(message);
7
- expect(error.statusCode).toEqual(500);
8
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { apiIndexingLogErrorMessage, InvalidPaginationTypeError, MissingIndexedShapeError } from "../index.js";
3
- test('MissingIndexedShapeError', () => {
4
- const error = new MissingIndexedShapeError('queryName');
5
- expect(error.message).toEqual('Could not find indexed shape for queryName. Verify that itemsPath is set correctly.');
6
- expect(error.code).toEqual('MissingIndexedShapeError');
7
- });
8
- test('InvalidPaginationTypeError', () => {
9
- const error = new InvalidPaginationTypeError(['page', 'cursor', 'offset']);
10
- expect(error.message).toEqual('Invalid pagination type. Valid types are page, cursor, offset.');
11
- expect(error.code).toEqual('InvalidPaginationTypeError');
12
- });
13
- describe('apiIndexingLogErrorMessage', () => {
14
- test('returns the message for an ApiIndexingError', () => {
15
- const error = new MissingIndexedShapeError('queryName');
16
- expect(apiIndexingLogErrorMessage('ShapeName', error)).toEqual(error.message);
17
- });
18
- test('returns the default otherwise', () => {
19
- const error = new Error('some error');
20
- expect(apiIndexingLogErrorMessage('ShapeName', error)).toEqual('Failed to index shape "ShapeName" due to an unexpected error.');
21
- });
22
- });