diff --git a/fastify.js b/fastify.js index 7a3829b91e..476c2a51e8 100644 --- a/fastify.js +++ b/fastify.js @@ -1,6 +1,6 @@ 'use strict' -const VERSION = '4.2.0' +const VERSION = '4.2.1' const Avvio = require('avvio') const http = require('http') diff --git a/lib/error-serializer.js b/lib/error-serializer.js index 480effc7b7..8e8b4f52a1 100644 --- a/lib/error-serializer.js +++ b/lib/error-serializer.js @@ -74,24 +74,24 @@ class Serializer { return bool === null ? 'null' : this.asBoolean(bool) } - asDatetime (date) { - const quotes = '"' + asDateTime (date) { + if (date === null) return '""' if (date instanceof Date) { - return quotes + date.toISOString() + quotes + return '"' + date.toISOString() + '"' } - return this.asString(date) + throw new Error(`The value "${date}" cannot be converted to a date-time.`) } - asDatetimeNullable (date) { - return date === null ? 'null' : this.asDatetime(date) + asDateTimeNullable (date) { + return date === null ? 'null' : this.asDateTime(date) } asDate (date) { - const quotes = '"' + if (date === null) return '""' if (date instanceof Date) { - return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(0, 10) + quotes + return '"' + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(0, 10) + '"' } - return this.asString(date) + throw new Error(`The value "${date}" cannot be converted to a date.`) } asDateNullable (date) { @@ -99,11 +99,11 @@ class Serializer { } asTime (date) { - const quotes = '"' + if (date === null) return '""' if (date instanceof Date) { - return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + quotes + return '"' + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + '"' } - return this.asString(date) + throw new Error(`The value "${date}" cannot be converted to a time.`) } asTimeNullable (date) { diff --git a/package.json b/package.json index 8b9f097d62..0387452b10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fastify", - "version": "4.2.0", + "version": "4.2.1", "description": "Fast and low overhead web framework, for Node.js", "main": "fastify.js", "type": "commonjs",