Git Product home page Git Product logo

error's Issues

TypeError: "name" is read-only

Hi,

I get the following error TypeError: "name" is read-only related to line 25 extend(createError, args); in file typed.js
.

Can you help me ?

checking err is SomeTypedError?

What is the right way to check an err is a ServerError?

var TypedError = require("error/typed")

var ServerError = TypedError({
    type: 'server.5xx',
    message: '{title} server error, status={statusCode}',
    title: null,
    statusCode: null
});

var error = new ServerError({
    title:'some title',
    statusCode: 500
});

error instanceof ServerError // false

or by using err.name, err.type or err.fullType? (what are all these properties for?)

Thanks!

[Request/Question] TypeScript definitions

Hi,

Could you provide typescript definitions for your package?
Unfortunately I didn't found community definitions (on DefinitelyTyped/DefinitelyTyped), and I'm not enough skilled to create one (I can try but it would take time :x).

Thanks,

Regards.

What Even Is `MIGRATION.md`?

So like a lot of projects are on 4.x... I'd like to use wrapped error, added somewhere after 5.?... and why not go to 7.x while I'm at it? Well there's no file to tell me why not, or what to do...

Add warning for 'illegal access' in node < 0.12

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.

Request: Default template string

It would be nice to call an error like so:

class CustomError extends SError {
  static defaultTemplate =  'there was a problem with foo: {foo}'
}

error = CustomError.create({foo: 'bar'})
// => error.message = 'there was a problem with foo: bar'

Having the message template defined with the error seems to separate responsibilities better: the error message knows how to display the error, and the call-site does not need to know that. Seems to me to better design in some cases, by moving more logic to the error object and away from the call-site.

use captureStackTrace for v8

v8 engine support Error.captureStackTrace to shift stacktrace to real place where error created.

Do you accept a PR to add this feature for only node.js/io.js?

License file missing

Hi,

Could you please add a LICENSE file to this repo. Noticed that the package.json mentions "license": "MIT". However i couldn't find LICENSE file.
This is causing issue in synk scan.

Thanks,
Deepali

Don't require `assert` module

Hey Jake and thanks for this module.

I'd really like to use this module for some simple error throwing in different low-level modules, but since this module depends on "assert" and "util" sadly that's not really an option.

By requiring assert and util (I'm only bothered by assert, because I use the "typed" errors), browserify will bundle all its builtins and this is a total bummer for small modules.

Maybe we could just throw instead of asserting? I know the code would be a bit more messy, but in return it'd make it much more light-weight.

I could make a PR if you're interested?

extend throws when run under strict mode

First off let me say thanks for all your open-source work! It is because of people like you I've learned some incredible things.

I also want to say I'm not sure what to do about this, or where the fix should lie so feel free to point the finger elsewhere ๐Ÿ˜„

This issue is related to this issue in cycle.js. cycle.js runs in strict mode. This recent commit ends up assigning the name property of source to the target function object createError which is usually a no-op but throws under strict mode with at least chrome.

Uncaught TypeError: Cannot assign to read only property 'name' of function createError(opts) {
            var result = new Error()... <more>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.