@rest-vir/implement-service 0.19.2 → 0.20.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.
@@ -1,3 +1,4 @@
1
+ import { HttpStatus } from '@augment-vir/common';
1
2
  /**
2
3
  * An error thrown internally from rest-vir while handling an request. This will not include errors
3
4
  * thrown by an endpoint or WebSocket implementation itself.
@@ -10,8 +11,9 @@
10
11
  * @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
11
12
  */
12
13
  export declare class RestVirHandlerError extends Error {
14
+ readonly status: HttpStatus;
13
15
  readonly name = "RestVirHandlerError";
14
- constructor(route: Parameters<typeof createRestVirHandlerErrorPrefix>[0], message: string);
16
+ constructor(route: Parameters<typeof createRestVirHandlerErrorPrefix>[0], message: string, status?: HttpStatus);
15
17
  }
16
18
  /**
17
19
  * Creates the handler error string used by {@link RestVirHandlerError}.
@@ -1,4 +1,4 @@
1
- import { combineErrorMessages } from '@augment-vir/common';
1
+ import { combineErrorMessages, HttpStatus } from '@augment-vir/common';
2
2
  /**
3
3
  * An error thrown internally from rest-vir while handling an request. This will not include errors
4
4
  * thrown by an endpoint or WebSocket implementation itself.
@@ -11,9 +11,11 @@ import { combineErrorMessages } from '@augment-vir/common';
11
11
  * @package [`@rest-vir/implement-service`](https://www.npmjs.com/package/@rest-vir/implement-service)
12
12
  */
13
13
  export class RestVirHandlerError extends Error {
14
+ status;
14
15
  name = 'RestVirHandlerError';
15
- constructor(route, message) {
16
+ constructor(route, message, status = HttpStatus.InternalServerError) {
16
17
  super(combineErrorMessages(createRestVirHandlerErrorPrefix(route), message));
18
+ this.status = status;
17
19
  }
18
20
  }
19
21
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rest-vir/implement-service",
3
- "version": "0.19.2",
3
+ "version": "0.20.0",
4
4
  "description": "Implement a service defined by @rest-vir/define-service.",
5
5
  "keywords": [
6
6
  "rest",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@augment-vir/assert": "^31.20.0",
43
43
  "@augment-vir/common": "^31.20.0",
44
- "@rest-vir/define-service": "^0.19.2",
44
+ "@rest-vir/define-service": "^0.20.0",
45
45
  "@types/ws": "^8.18.1",
46
46
  "fastify": "^5.3.3",
47
47
  "path-to-regexp": "^8.2.0",