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

Add warning for 'illegal access' in node < 0.12 #10

Closed
Willyham opened this issue Jun 16, 2015 · 1 comment
Closed

Add warning for 'illegal access' in node < 0.12 #10

Willyham opened this issue Jun 16, 2015 · 1 comment

Comments

@Willyham
Copy link

Using typed error and trying to log the error (or anything which causes toString to be called) results in a fatal 'illegal access' error in 0.10.x

willy@localhost:~/sync (willFetch)$ nave use 0.10
already using 0.10.38
willy@localhost:~/sync (willFetch)$ node
> var TypedError = require('error/typed')
undefined
> var Test = TypedError({type:'foo'})
undefined
> var e = Test()
undefined
> e

util.js:329
  return '[' + Error.prototype.toString.call(value) + ']';
                                        ^
illegal access

willy@localhost:~/sync/ (willFetch)$ nave use 0.12
Already installed: 0.12.4
using 0.12.4
willy@localhost:~/sync/ (willFetch)$ node
>  var TypedError = require('error/typed')
undefined
> var Test = TypedError({type:'foo'})
undefined
>  var e = Test()
undefined
> e
{ [FooError] type: 'foo', name: 'FooError', fullType: 'foo' }

Obviously this isn't something which can be fixed, but it's a hard to debug problem, so a warning in the readme would help here.

@Raynos
Copy link
Owner

Raynos commented Jun 17, 2015

@Willyham

raynos at raynos-MacBookPro  ~/projects/error on master
$ node
> var Typed = require('./typed')
undefined
> var MyError = Typed({ type: 'foo', message: 'bar' })
undefined
> var e = MyError()
undefined
> e
{ [FooError: bar]
  type: 'foo',
  message: 'bar',
  name: 'FooError',
  fullType: 'foo' }
> var MyError = Typed({ type: 'foo' })
AssertionError: TypedError: must specify options.message
    at TypedError (/home/raynos/projects/error/typed.js:14:5)
    at repl:1:15
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

I think your problem is that your creating an error object without a message.

In latest version of require('error') the message field is required and will never be unset.

Upgrade to master and make sure all your typed error classes have a message field.

@Raynos Raynos closed this as completed Jun 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants