Merge pull request #660 from simmayor/custom-errors

Custom-Errors: Fixed spelling
This commit is contained in:
Ilya Kantor 2018-12-24 12:44:44 +03:00 committed by GitHub
commit 8cae95a416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -185,7 +185,7 @@ try {
The new class `PropertyRequiredError` is easy to use: we only need to pass the property name: `new PropertyRequiredError(property)`. The human-readable `message` is generated by the constructor.
Please note that `this.name` in `PropertyRequiredError` constructor is again assigned manually. That may become a bit tedius -- to assign `this.name = <class name>` when creating each custom error. But there's a way out. We can make our own "basic error" class that removes this burden from our shoulders by using `this.constructor.name` for `this.name` in the constructor. And then inherit from it.
Please note that `this.name` in `PropertyRequiredError` constructor is again assigned manually. That may become a bit tedious -- to assign `this.name = <class name>` when creating each custom error. But there's a way out. We can make our own "basic error" class that removes this burden from our shoulders by using `this.constructor.name` for `this.name` in the constructor. And then inherit from it.
Let's call it `MyError`.