From 162d3a94e3f7a5de7abf4faedba095d45e9e0ea5 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Sat, 24 Dec 2022 09:21:31 +0900 Subject: [PATCH] doc: show output of example in http User can check output of example easily. PR-URL: https://github.com/nodejs/node/pull/45915 Reviewed-By: Antoine du Hamel Reviewed-By: Paolo Insogna Reviewed-By: Matteo Collina --- doc/api/http.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 37e3dfe5adb38a..fc56b0625f2dea 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -3622,9 +3622,9 @@ const { validateHeaderName } = require('node:http'); try { validateHeaderName(''); } catch (err) { - err instanceof TypeError; // --> true - err.code; // --> 'ERR_INVALID_HTTP_TOKEN' - err.message; // --> 'Header name must be a valid HTTP token [""]' + console.error(err instanceof TypeError); // --> true + console.error(err.code); // --> 'ERR_INVALID_HTTP_TOKEN' + console.error(err.message); // --> 'Header name must be a valid HTTP token [""]' } ``` @@ -3656,17 +3656,17 @@ const { validateHeaderValue } = require('node:http'); try { validateHeaderValue('x-my-header', undefined); } catch (err) { - err instanceof TypeError; // --> true - err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'; // --> true - err.message; // --> 'Invalid value "undefined" for header "x-my-header"' + console.error(err instanceof TypeError); // --> true + console.error(err.code === 'ERR_HTTP_INVALID_HEADER_VALUE'); // --> true + console.error(err.message); // --> 'Invalid value "undefined" for header "x-my-header"' } try { validateHeaderValue('x-my-header', 'oʊmɪɡə'); } catch (err) { - err instanceof TypeError; // --> true - err.code === 'ERR_INVALID_CHAR'; // --> true - err.message; // --> 'Invalid character in header content ["x-my-header"]' + console.error(err instanceof TypeError); // --> true + console.error(err.code === 'ERR_INVALID_CHAR'); // --> true + console.error(err.message); // --> 'Invalid character in header content ["x-my-header"]' } ```