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

can.map throws strings, not errors. #1773

Closed
akagomez opened this issue Jul 8, 2015 · 9 comments
Closed

can.map throws strings, not errors. #1773

akagomez opened this issue Jul 8, 2015 · 9 comments
Labels
Milestone

Comments

@akagomez
Copy link
Contributor

akagomez commented Jul 8, 2015

Currently:

throw "can.Map: Object does not exist";

Should be:

throw Error("can.Map: Object does not exist");

https://github.com/bitovi/canjs/blob/master/map/map.js#L495

/cc @imjoshdean

@imjoshdean
Copy link
Contributor

👍 Throwing strings don't provide things like stack traces and other Error goodies that are useful.

@imjoshdean imjoshdean self-assigned this Jul 8, 2015
@daffl
Copy link
Contributor

daffl commented Jul 8, 2015

👍 But I'm wondering if this could be considered a breaking API change?

@akagomez
Copy link
Contributor Author

akagomez commented Jul 8, 2015

Other instances I found:

./map/define/define_test.js:546:                        throw '"foo"\'s value method should not be called.';
./map/lazy/lazy.js:196:             throw "can.LazyMap: object does not exist";
./map/map.js:495:                       throw "can.Map: Object does not exist";
./util/fixture/fixture.js:108:                  throw "fixtures.js Error " + error + " " + message;
./view/parser/parser.js:236:                throw "Parse Error: " + html;
./view/view.js:46:          throw "can.view: No template or empty template:" + url;

@imjoshdean
Copy link
Contributor

I...don't think so? How would it break the API?

@justinbmeyer
Copy link
Contributor

It would not. We don't document these errors.

@daffl
Copy link
Contributor

daffl commented Jul 10, 2015

Shouldn't it be throw new Error("can.Map: Object does not exist");? Anyway, if it doesn't we can even get it into the 2.2.7 patch release.

@daffl daffl added this to the 2.2.8 milestone Jul 24, 2015
@justinbmeyer
Copy link
Contributor

@akagomez can you submit a pull request for this? Thanks!

@imjoshdean
Copy link
Contributor

@justinbmeyer I'm submitting one shortly, with more than just this throwing an error instead of a new string.

@akagomez
Copy link
Contributor Author

The PR: #1811

imjoshdean added a commit that referenced this issue Aug 28, 2015
Fixes #1773, throw Error objects rather than strings.
daffl added a commit that referenced this issue Sep 8, 2015
Fixes #1773, throw Error objects rather than strings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants