From 69aa8c7f812c739273473a7984af5d4daf8ab999 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Tue, 28 Jan 2025 20:34:05 +0000 Subject: [PATCH] refactor: throw typeerror if checking type (#505) --- index.js | 2 +- lib/dirList.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 58d8c84..ef80410 100644 --- a/index.js +++ b/index.js @@ -108,7 +108,7 @@ async function fastifyStatic (fastify, opts) { if (opts.serve !== false) { if (opts.wildcard && typeof opts.wildcard !== 'boolean') { - throw new Error('"wildcard" option must be a boolean') + throw new TypeError('"wildcard" option must be a boolean') } if (opts.wildcard === undefined || opts.wildcard === true) { fastify.route({ diff --git a/lib/dirList.js b/lib/dirList.js index f55319b..916ace6 100644 --- a/lib/dirList.js +++ b/lib/dirList.js @@ -108,7 +108,7 @@ const dirList = { */ send: async function ({ reply, dir, options, route, prefix, dotfiles }) { if (reply.request.query.format === 'html' && typeof options.render !== 'function') { - throw new Error('The `list.render` option must be a function and is required with the URL parameter `format=html`') + throw new TypeError('The `list.render` option must be a function and is required with the URL parameter `format=html`') } let entries