@fastify/error 3.2.1 → 3.3.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.
File without changes
File without changes
package/.taprc CHANGED
File without changes
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/index.js CHANGED
@@ -1,6 +1,10 @@
1
1
  'use strict'
2
2
 
3
- const { inherits, format } = require('util')
3
+ const { format } = require('util')
4
+
5
+ function toString () {
6
+ return `${this.name} [${this.code}]: ${this.message}`
7
+ }
4
8
 
5
9
  function createError (code, message, statusCode = 500, Base = Error) {
6
10
  if (!code) throw new Error('Fastify error code must not be empty')
@@ -22,13 +26,18 @@ function createError (code, message, statusCode = 500, Base = Error) {
22
26
  Error.stackTraceLimit !== 0 && Error.captureStackTrace(this, FastifyError)
23
27
  }
24
28
 
25
- FastifyError.prototype[Symbol.toStringTag] = 'Error'
29
+ FastifyError.prototype = Object.create(Base.prototype, {
30
+ constructor: {
31
+ value: FastifyError,
32
+ enumerable: false,
33
+ writable: true,
34
+ configurable: true
35
+ }
36
+ })
26
37
 
27
- FastifyError.prototype.toString = function () {
28
- return `${this.name} [${this.code}]: ${this.message}`
29
- }
38
+ FastifyError.prototype[Symbol.toStringTag] = 'Error'
30
39
 
31
- inherits(FastifyError, Base)
40
+ FastifyError.prototype.toString = toString
32
41
 
33
42
  return FastifyError
34
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastify/error",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "A small utility, used by Fastify itself, for generating consistent error objects across your codebase and plugins.",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
File without changes
package/types/index.d.ts CHANGED
File without changes
File without changes