From a94dd7e70de79b8d30c0c36ecd85c5c0401d33de Mon Sep 17 00:00:00 2001 From: Sergio Date: Tue, 25 Sep 2018 11:30:18 +0200 Subject: [PATCH] ES6 Class Syntax refactor (#250) * ES6 Class Syntax refactor * Capitalize Class name * Missing capitalisation in object --- sections/errorhandling/operationalvsprogrammererror.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sections/errorhandling/operationalvsprogrammererror.md b/sections/errorhandling/operationalvsprogrammererror.md index ebcc6d64..157c79eb 100644 --- a/sections/errorhandling/operationalvsprogrammererror.md +++ b/sections/errorhandling/operationalvsprogrammererror.md @@ -8,19 +8,21 @@ Distinguishing the following two error types will minimize your app downtime and ```javascript // marking an error object as operational -var myError = new Error("How can I add new product when no value provided?"); +const myError = new Error("How can I add new product when no value provided?"); myError.isOperational = true; // or if you're using some centralized error factory (see other examples at the bullet "Use only the built-in Error object") -function appError(commonType, description, isOperational) { +class AppError { + constructor (commonType, description, isOperational) { Error.call(this); Error.captureStackTrace(this); this.commonType = commonType; this.description = description; this.isOperational = isOperational; + } }; -throw new appError(errorManagement.commonErrors.InvalidInput, "Describe here what happened", true); +throw new AppError(errorManagement.commonErrors.InvalidInput, "Describe here what happened", true); ```