Browse Source

refactor: updates error messages

e22m4u 1 month ago
parent
commit
d4a8c47942

+ 46 - 46
dist/cjs/index.cjs

@@ -133,12 +133,12 @@ var import_js_format = require("@e22m4u/js-format");
 function createError(errorCtor, message, ...args) {
   if (typeof errorCtor !== "function")
     throw new import_js_format.Errorf(
-      'The first parameter of "createError" should be a constructor, but %v was given.',
+      'The first parameter of "createError" must be a constructor, but %v was given.',
       errorCtor
     );
   if (message != null && typeof message !== "string")
     throw new import_js_format.Errorf(
-      'The second parameter of "createError" should be a String, but %v was given.',
+      'The second parameter of "createError" must be a String, but %v was given.',
       message
     );
   if (message == null) return new errorCtor();
@@ -152,7 +152,7 @@ var import_js_format2 = require("@e22m4u/js-format");
 function toCamelCase(input) {
   if (typeof input !== "string")
     throw new import_js_format2.Errorf(
-      'The first parameter of "toCamelCase" should be a String, but %v was given.',
+      'The first parameter of "toCamelCase" must be a String, but %v was given.',
       input
     );
   return input.replace(/(^\w|[A-Z]|\b\w)/g, (c) => c.toUpperCase()).replace(/\W+/g, "").replace(/(^\w)/g, (c) => c.toLowerCase());
@@ -164,7 +164,7 @@ var import_js_format3 = require("@e22m4u/js-format");
 function isResponseSent(response) {
   if (!response || typeof response !== "object" || Array.isArray(response) || typeof response.headersSent !== "boolean") {
     throw new import_js_format3.Errorf(
-      'The first parameter of "isResponseSent" should be an instance of ServerResponse, but %v was given.',
+      'The first parameter of "isResponseSent" must be an instance of ServerResponse, but %v was given.',
       response
     );
   }
@@ -194,7 +194,7 @@ var import_js_format4 = require("@e22m4u/js-format");
 function parseContentType(input) {
   if (typeof input !== "string")
     throw new import_js_format4.Errorf(
-      "The first parameter of `parseContentType` should be a String, but %v was given.",
+      "The first parameter of `parseContentType` must be a String, but %v was given.",
       input
     );
   const res = { mediaType: void 0, charset: void 0, boundary: void 0 };
@@ -233,12 +233,12 @@ var CHARACTER_ENCODING_LIST = [
 function fetchRequestBody(request, bodyBytesLimit = 0) {
   if (!(request instanceof import_http.IncomingMessage))
     throw new import_js_format5.Errorf(
-      'The first parameter of "fetchRequestBody" should be an IncomingMessage instance, but %v was given.',
+      'The first parameter of "fetchRequestBody" must be an IncomingMessage instance, but %v was given.',
       request
     );
   if (typeof bodyBytesLimit !== "number")
     throw new import_js_format5.Errorf(
-      'The parameter "bodyBytesLimit" of "fetchRequestBody" should be a number, but %v was given.',
+      'The parameter "bodyBytesLimit" of "fetchRequestBody" must be a number, but %v was given.',
       bodyBytesLimit
     );
   return new Promise((resolve, reject) => {
@@ -339,7 +339,7 @@ var import_js_format7 = require("@e22m4u/js-format");
 function createCookieString(data) {
   if (!data || typeof data !== "object" || Array.isArray(data))
     throw new import_js_format7.Errorf(
-      'The first parameter of "createCookieString" should be an Object, but %v was given.',
+      'The first parameter of "createCookieString" must be an Object, but %v was given.',
       data
     );
   let cookies = "";
@@ -357,58 +357,58 @@ __name(createCookieString, "createCookieString");
 function createRequestMock(patch) {
   if (patch != null && typeof patch !== "object" || Array.isArray(patch)) {
     throw new import_js_format8.Errorf(
-      'The first parameter of "createRequestMock" should be an Object, but %v was given.',
+      'The first parameter of "createRequestMock" must be an Object, but %v was given.',
       patch
     );
   }
   patch = patch || {};
   if (patch.host != null && typeof patch.host !== "string")
     throw new import_js_format8.Errorf(
-      'The parameter "host" of "createRequestMock" should be a String, but %v was given.',
+      'The parameter "host" of "createRequestMock" must be a String, but %v was given.',
       patch.host
     );
   if (patch.method != null && typeof patch.method !== "string")
     throw new import_js_format8.Errorf(
-      'The parameter "method" of "createRequestMock" should be a String, but %v was given.',
+      'The parameter "method" of "createRequestMock" must be a String, but %v was given.',
       patch.method
     );
   if (patch.secure != null && typeof patch.secure !== "boolean")
     throw new import_js_format8.Errorf(
-      'The parameter "secure" of "createRequestMock" should be a Boolean, but %v was given.',
+      'The parameter "secure" of "createRequestMock" must be a Boolean, but %v was given.',
       patch.secure
     );
   if (patch.path != null && typeof patch.path !== "string")
     throw new import_js_format8.Errorf(
-      'The parameter "path" of "createRequestMock" should be a String, but %v was given.',
+      'The parameter "path" of "createRequestMock" must be a String, but %v was given.',
       patch.path
     );
   if (patch.query != null && typeof patch.query !== "object" && typeof patch.query !== "string" || Array.isArray(patch.query)) {
     throw new import_js_format8.Errorf(
-      'The parameter "query" of "createRequestMock" should be a String or Object, but %v was given.',
+      'The parameter "query" of "createRequestMock" must be a String or Object, but %v was given.',
       patch.query
     );
   }
   if (patch.cookies != null && typeof patch.cookies !== "string" && typeof patch.cookies !== "object" || Array.isArray(patch.cookies)) {
     throw new import_js_format8.Errorf(
-      'The parameter "cookies" of "createRequestMock" should be a String or Object, but %v was given.',
+      'The parameter "cookies" of "createRequestMock" must be a String or Object, but %v was given.',
       patch.cookies
     );
   }
   if (patch.headers != null && typeof patch.headers !== "object" || Array.isArray(patch.headers)) {
     throw new import_js_format8.Errorf(
-      'The parameter "headers" of "createRequestMock" should be an Object, but %v was given.',
+      'The parameter "headers" of "createRequestMock" must be an Object, but %v was given.',
       patch.headers
     );
   }
   if (patch.stream != null && !isReadableStream(patch.stream))
     throw new import_js_format8.Errorf(
-      'The parameter "stream" of "createRequestMock" should be a Stream, but %v was given.',
+      'The parameter "stream" of "createRequestMock" must be a Stream, but %v was given.',
       patch.stream
     );
   if (patch.encoding != null) {
     if (typeof patch.encoding !== "string")
       throw new import_js_format8.Errorf(
-        'The parameter "encoding" of "createRequestMock" should be a String, but %v was given.',
+        'The parameter "encoding" of "createRequestMock" must be a String, but %v was given.',
         patch.encoding
       );
     if (!CHARACTER_ENCODING_LIST.includes(patch.encoding))
@@ -448,7 +448,7 @@ __name(createRequestMock, "createRequestMock");
 function createRequestStream(secure, body, encoding) {
   if (encoding != null && typeof encoding !== "string")
     throw new import_js_format8.Errorf(
-      'The parameter "encoding" of "createRequestStream" should be a String, but %v was given.',
+      'The parameter "encoding" of "createRequestStream" must be a String, but %v was given.',
       encoding
     );
   encoding = encoding || "utf-8";
@@ -471,12 +471,12 @@ __name(createRequestStream, "createRequestStream");
 function createRequestUrl(path, query) {
   if (typeof path !== "string")
     throw new import_js_format8.Errorf(
-      'The parameter "path" of "createRequestUrl" should be a String, but %v was given.',
+      'The parameter "path" of "createRequestUrl" must be a String, but %v was given.',
       path
     );
   if (query != null && typeof query !== "string" && typeof query !== "object" || Array.isArray(query)) {
     throw new import_js_format8.Errorf(
-      'The parameter "query" of "createRequestUrl" should be a String or Object, but %v was given.',
+      'The parameter "query" of "createRequestUrl" must be a String or Object, but %v was given.',
       query
     );
   }
@@ -499,26 +499,26 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
   host = host || "localhost";
   if (secure != null && typeof secure !== "boolean")
     throw new import_js_format8.Errorf(
-      'The parameter "secure" of "createRequestHeaders" should be a String, but %v was given.',
+      'The parameter "secure" of "createRequestHeaders" must be a String, but %v was given.',
       secure
     );
   secure = Boolean(secure);
   if (cookies != null && typeof cookies !== "object" && typeof cookies !== "string" || Array.isArray(cookies)) {
     throw new import_js_format8.Errorf(
-      'The parameter "cookies" of "createRequestHeaders" should be a String or Object, but %v was given.',
+      'The parameter "cookies" of "createRequestHeaders" must be a String or Object, but %v was given.',
       cookies
     );
   }
   if (headers != null && typeof headers !== "object" || Array.isArray(headers)) {
     throw new import_js_format8.Errorf(
-      'The parameter "headers" of "createRequestHeaders" should be an Object, but %v was given.',
+      'The parameter "headers" of "createRequestHeaders" must be an Object, but %v was given.',
       headers
     );
   }
   headers = headers || {};
   if (encoding != null && typeof encoding !== "string")
     throw new import_js_format8.Errorf(
-      'The parameter "encoding" of "createRequestHeaders" should be a String, but %v was given.',
+      'The parameter "encoding" of "createRequestHeaders" must be a String, but %v was given.',
       encoding
     );
   encoding = encoding || "utf-8";
@@ -670,7 +670,7 @@ var import_js_format9 = require("@e22m4u/js-format");
 function getRequestPathname(request) {
   if (!request || typeof request !== "object" || Array.isArray(request) || typeof request.url !== "string") {
     throw new import_js_format9.Errorf(
-      'The first parameter of "getRequestPathname" should be an instance of IncomingMessage, but %v was given.',
+      'The first parameter of "getRequestPathname" must be an instance of IncomingMessage, but %v was given.',
       request
     );
   }
@@ -706,7 +706,7 @@ var _HookRegistry = class _HookRegistry {
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
     if (!hook || typeof hook !== "function")
       throw new import_js_format10.Errorf(
-        "The hook %v should be a Function, but %v was given.",
+        "The hook %v must be a Function, but %v was given.",
         type,
         hook
       );
@@ -729,7 +729,7 @@ var _HookRegistry = class _HookRegistry {
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
     if (!hook || typeof hook !== "function")
       throw new import_js_format10.Errorf(
-        "The hook %v should be a Function, but %v was given.",
+        "The hook %v must be a Function, but %v was given.",
         type,
         hook
       );
@@ -767,19 +767,19 @@ var _HookInvoker = class _HookInvoker extends DebuggableService {
   invokeAndContinueUntilValueReceived(route, hookType, response, ...args) {
     if (!route || !(route instanceof Route))
       throw new import_js_format11.Errorf(
-        'The parameter "route" of the HookInvoker.invokeAndContinueUntilValueReceived should be a Route instance, but %v was given.',
+        'The parameter "route" of the HookInvoker.invokeAndContinueUntilValueReceived must be a Route instance, but %v was given.',
         route
       );
     if (!hookType || typeof hookType !== "string")
       throw new import_js_format11.Errorf(
-        'The parameter "hookType" of the HookInvoker.invokeAndContinueUntilValueReceived should be a non-empty String, but %v was given.',
+        'The parameter "hookType" of the HookInvoker.invokeAndContinueUntilValueReceived must be a non-empty String, but %v was given.',
         hookType
       );
     if (!Object.values(RouterHookType).includes(hookType))
       throw new import_js_format11.Errorf("The hook type %v is not supported.", hookType);
     if (!response || typeof response !== "object" || Array.isArray(response) || typeof response.headersSent !== "boolean") {
       throw new import_js_format11.Errorf(
-        'The parameter "response" of the HookInvoker.invokeAndContinueUntilValueReceived should be a ServerResponse instance, but %v was given.',
+        'The parameter "response" of the HookInvoker.invokeAndContinueUntilValueReceived must be a ServerResponse instance, but %v was given.',
         response
       );
     }
@@ -924,30 +924,30 @@ var _Route = class _Route extends import_js_debug.Debuggable {
     });
     if (!routeDef || typeof routeDef !== "object" || Array.isArray(routeDef))
       throw new import_js_format12.Errorf(
-        "The first parameter of Route.constructor should be an Object, but %v was given.",
+        "The first parameter of Route.constructor must be an Object, but %v was given.",
         routeDef
       );
     if (!routeDef.method || typeof routeDef.method !== "string")
       throw new import_js_format12.Errorf(
-        'The option "method" of the Route should be a non-empty String, but %v was given.',
+        'The option "method" of the Route must be a non-empty String, but %v was given.',
         routeDef.method
       );
     this._method = routeDef.method.toUpperCase();
     if (typeof routeDef.path !== "string")
       throw new import_js_format12.Errorf(
-        'The option "path" of the Route should be a String, but %v was given.',
+        'The option "path" of the Route must be a String, but %v was given.',
         routeDef.path
       );
     this._path = routeDef.path;
     if (typeof routeDef.handler !== "function")
       throw new import_js_format12.Errorf(
-        'The option "handler" of the Route should be a Function, but %v was given.',
+        'The option "handler" of the Route must be a Function, but %v was given.',
         routeDef.handler
       );
     if (routeDef.meta != null) {
       if (typeof routeDef.meta !== "object" || Array.isArray(routeDef.meta))
         throw new import_js_format12.Errorf(
-          'The option "meta" of the Route should be a plain Object, but %v was given.',
+          'The option "meta" of the Route must be a plain Object, but %v was given.',
           routeDef.meta
         );
       this._meta = cloneDeep(routeDef.meta);
@@ -1052,12 +1052,12 @@ var _BodyParser = class _BodyParser extends DebuggableService {
   defineParser(mediaType, parser) {
     if (!mediaType || typeof mediaType !== "string")
       throw new import_js_format14.Errorf(
-        'The parameter "mediaType" of BodyParser.defineParser should be a non-empty String, but %v was given.',
+        'The parameter "mediaType" of BodyParser.defineParser must be a non-empty String, but %v was given.',
         mediaType
       );
     if (!parser || typeof parser !== "function")
       throw new import_js_format14.Errorf(
-        'The parameter "parser" of BodyParser.defineParser should be a Function, but %v was given.',
+        'The parameter "parser" of BodyParser.defineParser must be a Function, but %v was given.',
         parser
       );
     this._parsers[mediaType] = parser;
@@ -1072,7 +1072,7 @@ var _BodyParser = class _BodyParser extends DebuggableService {
   hasParser(mediaType) {
     if (!mediaType || typeof mediaType !== "string")
       throw new import_js_format14.Errorf(
-        'The parameter "mediaType" of BodyParser.hasParser should be a non-empty String, but %v was given.',
+        'The parameter "mediaType" of BodyParser.hasParser must be a non-empty String, but %v was given.',
         mediaType
       );
     return Boolean(this._parsers[mediaType]);
@@ -1086,7 +1086,7 @@ var _BodyParser = class _BodyParser extends DebuggableService {
   deleteParser(mediaType) {
     if (!mediaType || typeof mediaType !== "string")
       throw new import_js_format14.Errorf(
-        'The parameter "mediaType" of BodyParser.deleteParser should be a non-empty String, but %v was given.',
+        'The parameter "mediaType" of BodyParser.deleteParser must be a non-empty String, but %v was given.',
         mediaType
       );
     const parser = this._parsers[mediaType];
@@ -1230,7 +1230,7 @@ var _RequestParser = class _RequestParser extends DebuggableService {
   parse(request) {
     if (!(request instanceof import_http3.IncomingMessage))
       throw new import_js_format15.Errorf(
-        "The first parameter of RequestParser.parse should be an instance of IncomingMessage, but %v was given.",
+        "The first parameter of RequestParser.parse must be an instance of IncomingMessage, but %v was given.",
         request
       );
     const data = {};
@@ -1284,7 +1284,7 @@ var _RouteRegistry = class _RouteRegistry extends DebuggableService {
     const debug = this.getDebuggerFor(this.defineRoute);
     if (!routeDef || typeof routeDef !== "object" || Array.isArray(routeDef))
       throw new import_js_format16.Errorf(
-        "The route definition should be an Object, but %v was given.",
+        "The route definition must be an Object, but %v was given.",
         routeDef
       );
     const route = new Route(routeDef);
@@ -1493,27 +1493,27 @@ var _RequestContext = class _RequestContext {
   constructor(container, request, response, route) {
     if (!(0, import_js_service3.isServiceContainer)(container))
       throw new import_js_format17.Errorf(
-        'The parameter "container" of RequestContext.constructor should be an instance of ServiceContainer, but %v was given.',
+        'The parameter "container" of RequestContext.constructor must be an instance of ServiceContainer, but %v was given.',
         container
       );
     this._container = container;
     if (!request || typeof request !== "object" || Array.isArray(request) || !isReadableStream(request)) {
       throw new import_js_format17.Errorf(
-        'The parameter "request" of RequestContext.constructor should be an instance of IncomingMessage, but %v was given.',
+        'The parameter "request" of RequestContext.constructor must be an instance of IncomingMessage, but %v was given.',
         request
       );
     }
     this._request = request;
     if (!response || typeof response !== "object" || Array.isArray(response) || !isWritableStream(response)) {
       throw new import_js_format17.Errorf(
-        'The parameter "response" of RequestContext.constructor should be an instance of ServerResponse, but %v was given.',
+        'The parameter "response" of RequestContext.constructor must be an instance of ServerResponse, but %v was given.',
         response
       );
     }
     this._response = response;
     if (!(route instanceof Route)) {
       throw new import_js_format17.Errorf(
-        'The parameter "route" of RequestContext.constructor should be an instance of Route, but %v was given.',
+        'The parameter "route" of RequestContext.constructor must be an instance of Route, but %v was given.',
         route
       );
     }

+ 3 - 3
src/hooks/hook-invoker.js

@@ -22,14 +22,14 @@ export class HookInvoker extends DebuggableService {
       throw new Errorf(
         'The parameter "route" of ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
-          'should be a Route instance, but %v was given.',
+          'must be a Route instance, but %v was given.',
         route,
       );
     if (!hookType || typeof hookType !== 'string')
       throw new Errorf(
         'The parameter "hookType" of ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
-          'should be a non-empty String, but %v was given.',
+          'must be a non-empty String, but %v was given.',
         hookType,
       );
     if (!Object.values(RouterHookType).includes(hookType))
@@ -43,7 +43,7 @@ export class HookInvoker extends DebuggableService {
       throw new Errorf(
         'The parameter "response" of ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
-          'should be a ServerResponse instance, but %v was given.',
+          'must be a ServerResponse instance, but %v was given.',
         response,
       );
     }

+ 3 - 3
src/hooks/hook-invoker.spec.js

@@ -20,7 +20,7 @@ describe('HookInvoker', function () {
         format(
           'The parameter "route" of ' +
             'the HookInvoker.invokeAndContinueUntilValueReceived ' +
-            'should be a Route instance, but %s was given.',
+            'must be a Route instance, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -56,7 +56,7 @@ describe('HookInvoker', function () {
         format(
           'The parameter "hookType" of ' +
             'the HookInvoker.invokeAndContinueUntilValueReceived ' +
-            'should be a non-empty String, but %s was given.',
+            'must be a non-empty String, but %s was given.',
           v,
         );
       expect(throwable('')).to.throw(error('""'));
@@ -104,7 +104,7 @@ describe('HookInvoker', function () {
         format(
           'The parameter "response" of ' +
             'the HookInvoker.invokeAndContinueUntilValueReceived ' +
-            'should be a ServerResponse instance, but %s was given.',
+            'must be a ServerResponse instance, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));

+ 2 - 2
src/hooks/hook-registry.js

@@ -39,7 +39,7 @@ export class HookRegistry {
       throw new Errorf('The hook type %v is not supported.', type);
     if (!hook || typeof hook !== 'function')
       throw new Errorf(
-        'The hook %v should be a Function, but %v was given.',
+        'The hook %v must be a Function, but %v was given.',
         type,
         hook,
       );
@@ -63,7 +63,7 @@ export class HookRegistry {
       throw new Errorf('The hook type %v is not supported.', type);
     if (!hook || typeof hook !== 'function')
       throw new Errorf(
-        'The hook %v should be a Function, but %v was given.',
+        'The hook %v must be a Function, but %v was given.',
         type,
         hook,
       );

+ 2 - 2
src/hooks/hook-registry.spec.js

@@ -27,7 +27,7 @@ describe('HookRegistry', function () {
       const throwable = v => () => s.addHook(RouterHookType.PRE_HANDLER, v);
       const error = v =>
         format(
-          'The hook "preHandler" should be a Function, but %s was given.',
+          'The hook "preHandler" must be a Function, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -92,7 +92,7 @@ describe('HookRegistry', function () {
       const throwable = v => () => s.hasHook(RouterHookType.PRE_HANDLER, v);
       const error = v =>
         format(
-          'The hook "preHandler" should be a Function, but %s was given.',
+          'The hook "preHandler" must be a Function, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));

+ 4 - 4
src/parsers/body-parser.js

@@ -48,13 +48,13 @@ export class BodyParser extends DebuggableService {
     if (!mediaType || typeof mediaType !== 'string')
       throw new Errorf(
         'The parameter "mediaType" of BodyParser.defineParser ' +
-          'should be a non-empty String, but %v was given.',
+          'must be a non-empty String, but %v was given.',
         mediaType,
       );
     if (!parser || typeof parser !== 'function')
       throw new Errorf(
         'The parameter "parser" of BodyParser.defineParser ' +
-          'should be a Function, but %v was given.',
+          'must be a Function, but %v was given.',
         parser,
       );
     this._parsers[mediaType] = parser;
@@ -71,7 +71,7 @@ export class BodyParser extends DebuggableService {
     if (!mediaType || typeof mediaType !== 'string')
       throw new Errorf(
         'The parameter "mediaType" of BodyParser.hasParser ' +
-          'should be a non-empty String, but %v was given.',
+          'must be a non-empty String, but %v was given.',
         mediaType,
       );
     return Boolean(this._parsers[mediaType]);
@@ -87,7 +87,7 @@ export class BodyParser extends DebuggableService {
     if (!mediaType || typeof mediaType !== 'string')
       throw new Errorf(
         'The parameter "mediaType" of BodyParser.deleteParser ' +
-          'should be a non-empty String, but %v was given.',
+          'must be a non-empty String, but %v was given.',
         mediaType,
       );
     const parser = this._parsers[mediaType];

+ 4 - 4
src/parsers/body-parser.spec.js

@@ -19,7 +19,7 @@ describe('BodyParser', function () {
       const error = v =>
         format(
           'The parameter "mediaType" of BodyParser.defineParser ' +
-            'should be a non-empty String, but %s was given.',
+            'must be a non-empty String, but %s was given.',
           v,
         );
       expect(throwable('')).to.throw(error('""'));
@@ -41,7 +41,7 @@ describe('BodyParser', function () {
       const error = v =>
         format(
           'The parameter "parser" of BodyParser.defineParser ' +
-            'should be a Function, but %s was given.',
+            'must be a Function, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -79,7 +79,7 @@ describe('BodyParser', function () {
       const error = v =>
         format(
           'The parameter "mediaType" of BodyParser.hasParser ' +
-            'should be a non-empty String, but %s was given.',
+            'must be a non-empty String, but %s was given.',
           v,
         );
       expect(throwable('')).to.throw(error('""'));
@@ -114,7 +114,7 @@ describe('BodyParser', function () {
       const error = v =>
         format(
           'The parameter "mediaType" of BodyParser.deleteParser ' +
-            'should be a non-empty String, but %s was given.',
+            'must be a non-empty String, but %s was given.',
           v,
         );
       expect(throwable('')).to.throw(error('""'));

+ 1 - 1
src/parsers/request-parser.js

@@ -19,7 +19,7 @@ export class RequestParser extends DebuggableService {
   parse(request) {
     if (!(request instanceof IncomingMessage))
       throw new Errorf(
-        'The first parameter of RequestParser.parse should be ' +
+        'The first parameter of RequestParser.parse must be ' +
           'an instance of IncomingMessage, but %v was given.',
         request,
       );

+ 1 - 1
src/parsers/request-parser.spec.js

@@ -11,7 +11,7 @@ describe('RequestParser', function () {
       const throwable = v => () => s.parse(v);
       const error = v =>
         format(
-          'The first parameter of RequestParser.parse should be ' +
+          'The first parameter of RequestParser.parse must be ' +
             'an instance of IncomingMessage, but %s was given.',
           v,
         );

+ 4 - 4
src/request-context.js

@@ -176,7 +176,7 @@ export class RequestContext {
     if (!isServiceContainer(container))
       throw new Errorf(
         'The parameter "container" of RequestContext.constructor ' +
-          'should be an instance of ServiceContainer, but %v was given.',
+          'must be an instance of ServiceContainer, but %v was given.',
         container,
       );
     this._container = container;
@@ -188,7 +188,7 @@ export class RequestContext {
     ) {
       throw new Errorf(
         'The parameter "request" of RequestContext.constructor ' +
-          'should be an instance of IncomingMessage, but %v was given.',
+          'must be an instance of IncomingMessage, but %v was given.',
         request,
       );
     }
@@ -201,7 +201,7 @@ export class RequestContext {
     ) {
       throw new Errorf(
         'The parameter "response" of RequestContext.constructor ' +
-          'should be an instance of ServerResponse, but %v was given.',
+          'must be an instance of ServerResponse, but %v was given.',
         response,
       );
     }
@@ -209,7 +209,7 @@ export class RequestContext {
     if (!(route instanceof Route)) {
       throw new Errorf(
         'The parameter "route" of RequestContext.constructor ' +
-          'should be an instance of Route, but %v was given.',
+          'must be an instance of Route, but %v was given.',
         route,
       );
     }

+ 4 - 4
src/request-context.spec.js

@@ -19,7 +19,7 @@ describe('RequestContext', function () {
       const error = v =>
         format(
           'The parameter "container" of RequestContext.constructor ' +
-            'should be an instance of ServiceContainer, but %s was given.',
+            'must be an instance of ServiceContainer, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -43,7 +43,7 @@ describe('RequestContext', function () {
       const error = v =>
         format(
           'The parameter "request" of RequestContext.constructor ' +
-            'should be an instance of IncomingMessage, but %s was given.',
+            'must be an instance of IncomingMessage, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -67,7 +67,7 @@ describe('RequestContext', function () {
       const error = v =>
         format(
           'The parameter "response" of RequestContext.constructor ' +
-            'should be an instance of ServerResponse, but %s was given.',
+            'must be an instance of ServerResponse, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -91,7 +91,7 @@ describe('RequestContext', function () {
       const error = v =>
         format(
           'The parameter "route" of RequestContext.constructor ' +
-            'should be an instance of Route, but %s was given.',
+            'must be an instance of Route, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));

+ 1 - 1
src/route-registry.js

@@ -35,7 +35,7 @@ export class RouteRegistry extends DebuggableService {
     const debug = this.getDebuggerFor(this.defineRoute);
     if (!routeDef || typeof routeDef !== 'object' || Array.isArray(routeDef))
       throw new Errorf(
-        'The route definition should be an Object, but %v was given.',
+        'The route definition must be an Object, but %v was given.',
         routeDef,
       );
     const route = new Route(routeDef);

+ 1 - 4
src/route-registry.spec.js

@@ -10,10 +10,7 @@ describe('RouteRegistry', function () {
       const s = new RouteRegistry();
       const throwable = v => () => s.defineRoute(v);
       const error = v =>
-        format(
-          'The route definition should be an Object, but %s was given.',
-          v,
-        );
+        format('The route definition must be an Object, but %s was given.', v);
       expect(throwable('str')).to.throw(error('"str"'));
       expect(throwable('')).to.throw(error('""'));
       expect(throwable(10)).to.throw(error('10'));

+ 5 - 5
src/route.js

@@ -140,33 +140,33 @@ export class Route extends Debuggable {
     if (!routeDef || typeof routeDef !== 'object' || Array.isArray(routeDef))
       throw new Errorf(
         'The first parameter of Route.constructor ' +
-          'should be an Object, but %v was given.',
+          'must be an Object, but %v was given.',
         routeDef,
       );
     if (!routeDef.method || typeof routeDef.method !== 'string')
       throw new Errorf(
-        'The option "method" of the Route should be ' +
+        'The option "method" of the Route must be ' +
           'a non-empty String, but %v was given.',
         routeDef.method,
       );
     this._method = routeDef.method.toUpperCase();
     if (typeof routeDef.path !== 'string')
       throw new Errorf(
-        'The option "path" of the Route should be ' +
+        'The option "path" of the Route must be ' +
           'a String, but %v was given.',
         routeDef.path,
       );
     this._path = routeDef.path;
     if (typeof routeDef.handler !== 'function')
       throw new Errorf(
-        'The option "handler" of the Route should be ' +
+        'The option "handler" of the Route must be ' +
           'a Function, but %v was given.',
         routeDef.handler,
       );
     if (routeDef.meta != null) {
       if (typeof routeDef.meta !== 'object' || Array.isArray(routeDef.meta))
         throw new Errorf(
-          'The option "meta" of the Route should be ' +
+          'The option "meta" of the Route must be ' +
             'a plain Object, but %v was given.',
           routeDef.meta,
         );

+ 7 - 7
src/route.spec.js

@@ -13,7 +13,7 @@ describe('Route', function () {
       const error = v =>
         format(
           'The first parameter of Route.constructor ' +
-            'should be an Object, but %s was given.',
+            'must be an Object, but %s was given.',
           v,
         );
       expect(throwable('str')).to.throw(error('"str"'));
@@ -43,7 +43,7 @@ describe('Route', function () {
           });
         const error = v =>
           format(
-            'The option "method" of the Route should be ' +
+            'The option "method" of the Route must be ' +
               'a non-empty String, but %s was given.',
             v,
           );
@@ -80,7 +80,7 @@ describe('Route', function () {
           });
         const error = v =>
           format(
-            'The option "path" of the Route should be ' +
+            'The option "path" of the Route must be ' +
               'a String, but %s was given.',
             v,
           );
@@ -119,7 +119,7 @@ describe('Route', function () {
           });
         const error = v =>
           format(
-            'The option "meta" of the Route should be ' +
+            'The option "meta" of the Route must be ' +
               'a plain Object, but %s was given.',
             v,
           );
@@ -191,7 +191,7 @@ describe('Route', function () {
           });
         const error = v =>
           format(
-            'The option "handler" of the Route should be ' +
+            'The option "handler" of the Route must be ' +
               'a Function, but %s was given.',
             v,
           );
@@ -230,7 +230,7 @@ describe('Route', function () {
           });
         const error = v =>
           format(
-            'The hook "preHandler" should be a Function, but %s was given.',
+            'The hook "preHandler" must be a Function, but %s was given.',
             v,
           );
         expect(throwable1('str')).to.throw(error('"str"'));
@@ -302,7 +302,7 @@ describe('Route', function () {
           });
         const error = v =>
           format(
-            'The hook "postHandler" should be a Function, but %s was given.',
+            'The hook "postHandler" must be a Function, but %s was given.',
             v,
           );
         expect(throwable1('str')).to.throw(error('"str"'));

+ 1 - 1
src/utils/create-cookie-string.js

@@ -9,7 +9,7 @@ import {Errorf} from '@e22m4u/js-format';
 export function createCookieString(data) {
   if (!data || typeof data !== 'object' || Array.isArray(data))
     throw new Errorf(
-      'The first parameter of "createCookieString" should be ' +
+      'The first parameter of "createCookieString" must be ' +
         'an Object, but %v was given.',
       data,
     );

+ 1 - 1
src/utils/create-cookie-string.spec.js

@@ -7,7 +7,7 @@ describe('createCookieString', function () {
     const throwable = v => () => createCookieString(v);
     const error = v =>
       format(
-        'The first parameter of "createCookieString" should be ' +
+        'The first parameter of "createCookieString" must be ' +
           'an Object, but %s was given.',
         v,
       );

+ 2 - 2
src/utils/create-error.js

@@ -11,13 +11,13 @@ import {format, Errorf} from '@e22m4u/js-format';
 export function createError(errorCtor, message, ...args) {
   if (typeof errorCtor !== 'function')
     throw new Errorf(
-      'The first parameter of "createError" should be ' +
+      'The first parameter of "createError" must be ' +
         'a constructor, but %v was given.',
       errorCtor,
     );
   if (message != null && typeof message !== 'string')
     throw new Errorf(
-      'The second parameter of "createError" should be ' +
+      'The second parameter of "createError" must be ' +
         'a String, but %v was given.',
       message,
     );

+ 2 - 2
src/utils/create-error.spec.js

@@ -7,7 +7,7 @@ describe('createError', function () {
     const throwable = v => () => createError(v);
     const error = v =>
       format(
-        'The first parameter of "createError" should be ' +
+        'The first parameter of "createError" must be ' +
           'a constructor, but %s was given.',
         v,
       );
@@ -28,7 +28,7 @@ describe('createError', function () {
     const throwable = v => () => createError(Error, v);
     const error = v =>
       format(
-        'The second parameter of "createError" should be ' +
+        'The second parameter of "createError" must be ' +
           'a String, but %s was given.',
         v,
       );

+ 17 - 17
src/utils/create-request-mock.js

@@ -32,7 +32,7 @@ export function createRequestMock(patch) {
   if ((patch != null && typeof patch !== 'object') || Array.isArray(patch)) {
     throw new Errorf(
       'The first parameter of "createRequestMock" ' +
-        'should be an Object, but %v was given.',
+        'must be an Object, but %v was given.',
       patch,
     );
   }
@@ -40,25 +40,25 @@ export function createRequestMock(patch) {
   if (patch.host != null && typeof patch.host !== 'string')
     throw new Errorf(
       'The parameter "host" of "createRequestMock" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       patch.host,
     );
   if (patch.method != null && typeof patch.method !== 'string')
     throw new Errorf(
       'The parameter "method" of "createRequestMock" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       patch.method,
     );
   if (patch.secure != null && typeof patch.secure !== 'boolean')
     throw new Errorf(
       'The parameter "secure" of "createRequestMock" ' +
-        'should be a Boolean, but %v was given.',
+        'must be a Boolean, but %v was given.',
       patch.secure,
     );
   if (patch.path != null && typeof patch.path !== 'string')
     throw new Errorf(
       'The parameter "path" of "createRequestMock" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       patch.path,
     );
   if (
@@ -69,7 +69,7 @@ export function createRequestMock(patch) {
   ) {
     throw new Errorf(
       'The parameter "query" of "createRequestMock" ' +
-        'should be a String or Object, but %v was given.',
+        'must be a String or Object, but %v was given.',
       patch.query,
     );
   }
@@ -81,7 +81,7 @@ export function createRequestMock(patch) {
   ) {
     throw new Errorf(
       'The parameter "cookies" of "createRequestMock" ' +
-        'should be a String or Object, but %v was given.',
+        'must be a String or Object, but %v was given.',
       patch.cookies,
     );
   }
@@ -91,21 +91,21 @@ export function createRequestMock(patch) {
   ) {
     throw new Errorf(
       'The parameter "headers" of "createRequestMock" ' +
-        'should be an Object, but %v was given.',
+        'must be an Object, but %v was given.',
       patch.headers,
     );
   }
   if (patch.stream != null && !isReadableStream(patch.stream))
     throw new Errorf(
       'The parameter "stream" of "createRequestMock" ' +
-        'should be a Stream, but %v was given.',
+        'must be a Stream, but %v was given.',
       patch.stream,
     );
   if (patch.encoding != null) {
     if (typeof patch.encoding !== 'string')
       throw new Errorf(
         'The parameter "encoding" of "createRequestMock" ' +
-          'should be a String, but %v was given.',
+          'must be a String, but %v was given.',
         patch.encoding,
       );
     if (!CHARACTER_ENCODING_LIST.includes(patch.encoding))
@@ -164,7 +164,7 @@ function createRequestStream(secure, body, encoding) {
   if (encoding != null && typeof encoding !== 'string')
     throw new Errorf(
       'The parameter "encoding" of "createRequestStream" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       encoding,
     );
   encoding = encoding || 'utf-8';
@@ -201,7 +201,7 @@ function createRequestUrl(path, query) {
   if (typeof path !== 'string')
     throw new Errorf(
       'The parameter "path" of "createRequestUrl" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       path,
     );
   if (
@@ -210,7 +210,7 @@ function createRequestUrl(path, query) {
   ) {
     throw new Errorf(
       'The parameter "query" of "createRequestUrl" ' +
-        'should be a String or Object, but %v was given.',
+        'must be a String or Object, but %v was given.',
       query,
     );
   }
@@ -246,7 +246,7 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
   if (secure != null && typeof secure !== 'boolean')
     throw new Errorf(
       'The parameter "secure" of "createRequestHeaders" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       secure,
     );
   secure = Boolean(secure);
@@ -258,7 +258,7 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
   ) {
     throw new Errorf(
       'The parameter "cookies" of "createRequestHeaders" ' +
-        'should be a String or Object, but %v was given.',
+        'must be a String or Object, but %v was given.',
       cookies,
     );
   }
@@ -268,7 +268,7 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
   ) {
     throw new Errorf(
       'The parameter "headers" of "createRequestHeaders" ' +
-        'should be an Object, but %v was given.',
+        'must be an Object, but %v was given.',
       headers,
     );
   }
@@ -276,7 +276,7 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
   if (encoding != null && typeof encoding !== 'string')
     throw new Errorf(
       'The parameter "encoding" of "createRequestHeaders" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       encoding,
     );
   encoding = encoding || 'utf-8';

+ 10 - 10
src/utils/create-request-mock.spec.js

@@ -12,7 +12,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The first parameter of "createRequestMock" ' +
-          'should be an Object, but %s was given.',
+          'must be an Object, but %s was given.',
         v,
       );
     expect(throwable('str')).to.throw(error('"str"'));
@@ -32,7 +32,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "host" of "createRequestMock" ' +
-          'should be a String, but %s was given.',
+          'must be a String, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));
@@ -52,7 +52,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "method" of "createRequestMock" ' +
-          'should be a String, but %s was given.',
+          'must be a String, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));
@@ -72,7 +72,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "secure" of "createRequestMock" ' +
-          'should be a Boolean, but %s was given.',
+          'must be a Boolean, but %s was given.',
         v,
       );
     expect(throwable('str')).to.throw(error('"str"'));
@@ -92,7 +92,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "path" of "createRequestMock" ' +
-          'should be a String, but %s was given.',
+          'must be a String, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));
@@ -112,7 +112,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "query" of "createRequestMock" ' +
-          'should be a String or Object, but %s was given.',
+          'must be a String or Object, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));
@@ -133,7 +133,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "cookies" of "createRequestMock" ' +
-          'should be a String or Object, but %s was given.',
+          'must be a String or Object, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));
@@ -154,7 +154,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "headers" of "createRequestMock" ' +
-          'should be an Object, but %s was given.',
+          'must be an Object, but %s was given.',
         v,
       );
     expect(throwable('str')).to.throw(error('"str"'));
@@ -175,7 +175,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "stream" of "createRequestMock" ' +
-          'should be a Stream, but %s was given.',
+          'must be a Stream, but %s was given.',
         v,
       );
     expect(throwable('str')).to.throw(error('"str"'));
@@ -196,7 +196,7 @@ describe('createRequestMock', function () {
     const error = v =>
       format(
         'The parameter "encoding" of "createRequestMock" ' +
-          'should be a String, but %s was given.',
+          'must be a String, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));

+ 2 - 2
src/utils/fetch-request-body.js

@@ -28,14 +28,14 @@ export const CHARACTER_ENCODING_LIST = [
 export function fetchRequestBody(request, bodyBytesLimit = 0) {
   if (!(request instanceof IncomingMessage))
     throw new Errorf(
-      'The first parameter of "fetchRequestBody" should be ' +
+      'The first parameter of "fetchRequestBody" must be ' +
         'an IncomingMessage instance, but %v was given.',
       request,
     );
   if (typeof bodyBytesLimit !== 'number')
     throw new Errorf(
       'The parameter "bodyBytesLimit" of "fetchRequestBody" ' +
-        'should be a number, but %v was given.',
+        'must be a number, but %v was given.',
       bodyBytesLimit,
     );
   return new Promise((resolve, reject) => {

+ 2 - 2
src/utils/fetch-request-body.spec.js

@@ -8,7 +8,7 @@ describe('fetchRequestBody', function () {
     const throwable = v => () => fetchRequestBody(v);
     const error = v =>
       format(
-        'The first parameter of "fetchRequestBody" should be ' +
+        'The first parameter of "fetchRequestBody" must be ' +
           'an IncomingMessage instance, but %s was given.',
         v,
       );
@@ -31,7 +31,7 @@ describe('fetchRequestBody', function () {
     const error = v =>
       format(
         'The parameter "bodyBytesLimit" of "fetchRequestBody" ' +
-          'should be a number, but %s was given.',
+          'must be a number, but %s was given.',
         v,
       );
     expect(throwable('str')).to.throw(error('"str"'));

+ 1 - 1
src/utils/get-request-pathname.js

@@ -14,7 +14,7 @@ export function getRequestPathname(request) {
     typeof request.url !== 'string'
   ) {
     throw new Errorf(
-      'The first parameter of "getRequestPathname" should be ' +
+      'The first parameter of "getRequestPathname" must be ' +
         'an instance of IncomingMessage, but %v was given.',
       request,
     );

+ 1 - 1
src/utils/get-request-pathname.spec.js

@@ -7,7 +7,7 @@ describe('getRequestPathname', function () {
     const throwable = v => () => getRequestPathname(v);
     const error = v =>
       format(
-        'The first parameter of "getRequestPathname" should be ' +
+        'The first parameter of "getRequestPathname" must be ' +
           'an instance of IncomingMessage, but %s was given.',
         v,
       );

+ 1 - 1
src/utils/is-response-sent.js

@@ -14,7 +14,7 @@ export function isResponseSent(response) {
     typeof response.headersSent !== 'boolean'
   ) {
     throw new Errorf(
-      'The first parameter of "isResponseSent" should be ' +
+      'The first parameter of "isResponseSent" must be ' +
         'an instance of ServerResponse, but %v was given.',
       response,
     );

+ 1 - 1
src/utils/is-response-sent.spec.js

@@ -7,7 +7,7 @@ describe('isResponseSent', function () {
     const throwable = v => () => isResponseSent(v);
     const error = v =>
       format(
-        'The first parameter of "isResponseSent" should be ' +
+        'The first parameter of "isResponseSent" must be ' +
           'an instance of ServerResponse, but %s was given.',
         v,
       );

+ 1 - 1
src/utils/parse-content-type.js

@@ -14,7 +14,7 @@ export function parseContentType(input) {
   if (typeof input !== 'string')
     throw new Errorf(
       'The first parameter of `parseContentType` ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       input,
     );
   const res = {mediaType: undefined, charset: undefined, boundary: undefined};

+ 1 - 1
src/utils/parse-content-type.spec.js

@@ -8,7 +8,7 @@ describe('parseContentType', function () {
     const error = s =>
       format(
         'The first parameter of `parseContentType` ' +
-          'should be a String, but %s was given.',
+          'must be a String, but %s was given.',
         s,
       );
     expect(throwable(10)).to.throw(error('10'));

+ 1 - 1
src/utils/to-camel-case.js

@@ -10,7 +10,7 @@ export function toCamelCase(input) {
   if (typeof input !== 'string')
     throw new Errorf(
       'The first parameter of "toCamelCase" ' +
-        'should be a String, but %v was given.',
+        'must be a String, but %v was given.',
       input,
     );
   return input

+ 1 - 1
src/utils/to-camel-case.spec.js

@@ -8,7 +8,7 @@ describe('toCamelCase', function () {
     const error = v =>
       format(
         'The first parameter of "toCamelCase" ' +
-          'should be a String, but %s was given.',
+          'must be a String, but %s was given.',
         v,
       );
     expect(throwable(10)).to.throw(error('10'));