Skip to content

Commit

Permalink
Fix error constructor shim
Browse files Browse the repository at this point in the history
Error constructor should work even when calling without `new`
  • Loading branch information
petkaantonov committed Jan 28, 2014
1 parent f0e4b5c commit 70f01e4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function canAttach(obj) {

function subError(nameProperty, defaultMessage) {
function SubError(message) {
if (!(this instanceof SubError)) return new SubError(message);
this.message = typeof message === "string" ? message : defaultMessage;
this.name = nameProperty;
if (Error.captureStackTrace) {
Expand Down

0 comments on commit 70f01e4

Please sign in to comment.