Details
-
Story
-
Resolution: Fixed
-
Medium
-
None
-
5.2-alpha1
Description
- The Error should have defined fields instead of utilizing a object literal wrapping approach.
- An Error should always recieve a message as first argument. Arbitrary fields may be added after this.
- Having a defined Error structure allows for more generic error handling
- If different error types are needed those should be created as different error classes
- All custom errors should inherit from the default Error prototype. In order to allow proper handling as well as proper StackTraces:
var CAPIError = function (message, something, else) { this.name = "CAPIError"; this.message = message; } CAPIError.prototype = new Error(); CAPIError.prototype.constructor = CAPIError