@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.
- package/.github/dependabot.yml +0 -0
- package/.github/workflows/ci.yml +0 -0
- package/.taprc +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/benchmarks/create.js +0 -0
- package/benchmarks/instantiate.js +0 -0
- package/benchmarks/no-stack.js +0 -0
- package/benchmarks/toString.js +0 -0
- package/index.js +15 -6
- package/package.json +1 -1
- package/test/index.test.js +0 -0
- package/types/index.d.ts +0 -0
- package/types/index.test-d.ts +0 -0
package/.github/dependabot.yml
CHANGED
|
File without changes
|
package/.github/workflows/ci.yml
CHANGED
|
File without changes
|
package/.taprc
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/benchmarks/create.js
CHANGED
|
File without changes
|
|
File without changes
|
package/benchmarks/no-stack.js
CHANGED
|
File without changes
|
package/benchmarks/toString.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
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
|
|
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.
|
|
28
|
-
return `${this.name} [${this.code}]: ${this.message}`
|
|
29
|
-
}
|
|
38
|
+
FastifyError.prototype[Symbol.toStringTag] = 'Error'
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
FastifyError.prototype.toString = toString
|
|
32
41
|
|
|
33
42
|
return FastifyError
|
|
34
43
|
}
|
package/package.json
CHANGED
package/test/index.test.js
CHANGED
|
File without changes
|
package/types/index.d.ts
CHANGED
|
File without changes
|
package/types/index.test-d.ts
CHANGED
|
File without changes
|