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

Stop using new Error(...) in reject() #449

Closed
rwaldron opened this issue Nov 16, 2015 · 4 comments
Closed

Stop using new Error(...) in reject() #449

rwaldron opened this issue Nov 16, 2015 · 4 comments

Comments

@rwaldron
Copy link
Contributor

When reject(new Error(...)) is called, closeFailedCommand (in bin/tessel-2.js) does this:

  if (err instanceof Error) {
    throw err;
  } else {

Which means this happens:

Unhandled rejection Error: blah blah blah

...Followed by the entire stack trace.

Passing a string will log the string as a warning.

@rwaldron rwaldron changed the title Stop using new Error(...) in rejec() Stop using new Error(...) in rejec()t Nov 16, 2015
@rwaldron rwaldron changed the title Stop using new Error(...) in rejec()t Stop using new Error(...) in reject() Nov 16, 2015
@rwaldron
Copy link
Contributor Author

Or should it just use logs.err when the argument is actually a new Error() object?

@rwaldron
Copy link
Contributor Author

Here's an example, where instead of rethrowing and doing absolutely nothing with it, t2 will log an error instead.

Before:

$ t2 provision
Unhandled rejection Error: No key provided to set as default.
    at /Users/rwaldron/clonez/t2-cli/lib/tessel/provision.js:160:21
    at Object.actions.setDefaultKey (/Users/rwaldron/clonez/t2-cli/lib/tessel/provision.js:157:10)
    at Function.Tessel.get (/Users/rwaldron/clonez/t2-cli/lib/controller.js:121:20)
    at /Users/rwaldron/clonez/t2-cli/lib/controller.js:280:19
    at tryCatcher (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._resolveFromResolver (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/promise.js:480:31)
    at new Promise (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/promise.js:70:37)
    at Object.controller.standardTesselCommand (/Users/rwaldron/clonez/t2-cli/lib/controller.js:278:10)
    at executeProvision (/Users/rwaldron/clonez/t2-cli/lib/controller.js:517:25)
    at tryCatcher (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise._settlePromiseAt (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise._settlePromiseAtPostResolution (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/promise.js:245:10)
    at Async._drainQueue (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/async.js:128:12)
    at Async._drainQueues (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/rwaldron/clonez/t2-cli/node_modules/bluebird/js/main/async.js:15:14)

After:

$ t2 provision
ERR! Error: No key provided to set as default.

@rwaldron
Copy link
Contributor Author

(note that was done on an older branch, I just needed something to demonstrate with)

@rwaldron
Copy link
Contributor Author

This blocks #444

rwaldron added a commit to rwaldron/t2-cli that referenced this issue Nov 16, 2015
rwaldron added a commit to rwaldron/t2-cli that referenced this issue Nov 16, 2015
rwaldron added a commit that referenced this issue Nov 17, 2015
Instead of rethrowing errors, log them. Fixes gh-449
rwaldron added a commit that referenced this issue Nov 17, 2015
# By Rick Waldron (9) and others
# Via Rick Waldron (7) and others
* 'master' of github.com:tessel/t2-cli: (21 commits)
  Add appveyor badge to readme
  Instead of rethrowing errors, log them. Fixes gh-449
  Fix jscs error: dont use future reserved words as identifiers
  Updating grunt-jscs
  fix(access-point): removes template literals cause jsbeautify
  Tweak status messages
  replaces new Errors with strings
  fix(access-point): creates boilerplate for new access point when required
  Adds check step to AP setup. Needs AP _new_ iface.
  fix(ap/wifi): working implementation
  refactor(access-point): simpler, cleaner tests and source code
  tests(access-point): initial implementation
  feat(access-point): adds ability to enable/disable AP
  fix: working access point configuration
  fix(ap): now able to configure ap setup
  feat(ap): initial access point creation implementation
  When single flag is present, do not traverse upward for package.json. Fixes gh-442
  Ensure that bundling errors make are surfaced. Fixes gh-441
  Adding linux driver install
  only set key if requested
  ...

Conflicts:
	lib/controller.js
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

1 participant