From 36af008cc7e2c70e0aa50aff09a106c56d339c0c Mon Sep 17 00:00:00 2001 From: Mitja O Date: Wed, 11 Jul 2018 00:46:29 +0200 Subject: [PATCH] Constructor function in error should be uppercase Its perhaps a small thing but important for newbies I guess as constructor classes (functions) are usually uppercased in javascript: https://stackoverflow.com/questions/1564398/javascript-method-naming-lowercase-vs-uppercase --- sections/errorhandling/useonlythebuiltinerror.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sections/errorhandling/useonlythebuiltinerror.md b/sections/errorhandling/useonlythebuiltinerror.md index 7898f331..794ceb6b 100644 --- a/sections/errorhandling/useonlythebuiltinerror.md +++ b/sections/errorhandling/useonlythebuiltinerror.md @@ -36,20 +36,20 @@ if(!productToAdd) ```javascript // centralized error object that derives from Node’s Error -function appError(name, httpCode, description, isOperational) { +function AppError(name, httpCode, description, isOperational) { Error.call(this); Error.captureStackTrace(this); this.name = name; //...other properties assigned here }; -appError.prototype.__proto__ = Error.prototype; +AppError.prototype.__proto__ = Error.prototype; -module.exports.appError = appError; +module.exports.AppError = AppError; // client throwing an exception if(user == null) - throw new appError(commonErrors.resourceNotFound, commonHTTPErrors.notFound, "further explanation", true) + throw new AppError(commonErrors.resourceNotFound, commonHTTPErrors.notFound, "further explanation", true) ``` ### Blog Quote: "I don’t see the value in having lots of different types"