ES6 Class Syntax refactor (#250)

* ES6 Class Syntax refactor

* Capitalize Class name

* Missing capitalisation in object
This commit is contained in:
Sergio
2018-09-25 11:30:18 +02:00
committed by Sagir Khan
parent 7de275d31e
commit a94dd7e70d

View File

@ -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);
```