Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix callee for strict mode #18

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ function init (type, message, cause) {
}

// generic prototype, not intended to be actually used - helpful for `instanceof`
function CustomError (message, cause) {
var CustomError = function f(message, cause) {
Error.call(this)
if (Error.captureStackTrace)
Error.captureStackTrace(this, arguments.callee)
Error.captureStackTrace(this, f)
init.call(this, 'CustomError', message, cause)
}

CustomError.prototype = new Error()

function createError (errno, type, proto) {
var createError = function f(errno, type, proto) {
var err = function (message, cause) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more correct to use the inner anonymous function instead, since it's actually part of the callstack when the error is created (i.e. not when the error type is created).

init.call(this, type, message, cause)
//TODO: the specificity here is stupid, errno should be available everywhere
Expand All @@ -37,7 +37,7 @@ function createError (errno, type, proto) {
}
Error.call(this)
if (Error.captureStackTrace)
Error.captureStackTrace(this, arguments.callee)
Error.captureStackTrace(this, f)
}
err.prototype = !!proto ? new proto() : new CustomError()
return err
Expand Down