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

Handle output error strings #426

Merged
merged 2 commits into from Apr 23, 2019
Merged

Handle output error strings #426

merged 2 commits into from Apr 23, 2019

Conversation

piotr-cz
Copy link
Contributor

Platforms affected

all

Host OS: at least Windows

Motivation and Context

Properly output error strings

Description

When command rejects with a string, it's special characters like newlines and tabs are not formatted,

Example:

cordova platform update cordova-ios --save

Using cordova-fetch for cordova-ios
Updating ios project...
CordovaError: Promise rejected with non-error: 'An in-place platform update is not supported. \nThe `platforms` folder is always treated as a build artifact.\nTo update your platform, you have to remove, then add your ios platform again.\nMake sure you save your plugins beforehand using `cordova plugin save`, and save a copy of the platform first if you had manual changes in it.\n\tcordova plugin save\n\tcordova platform rm ios\n\tcordova platform add ios\n'
    at cli.catch.err (xxx\node_modules\cordova\bin\cordova:29:15)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

After:

cordova platform update cordova-ios --save
Using cordova-fetch for cordova-ios
Updating ios project...
CordovaError: Promise rejected with non-error: An in-place platform update is not supported.
The `platforms` folder is always treated as a build artifact.
To update your platform, you have to remove, then add your ios platform again.
Make sure you save your plugins beforehand using `cordova plugin save`, and save a copy of the platform first if you had manual changes in it.
        cordova plugin save
        cordova platform rm ios
        cordova platform add ios

    at cli.catch.err (xxx\node_modules\cordova\bin\cordova:33:15)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

Testing

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@project-bot project-bot bot added this to 🐣 New PR / Untriaged in Apache Cordova: Tooling Pull Requests Apr 23, 2019
Copy link
Contributor

@raphinesse raphinesse left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Thanks for the contribution.

Apache Cordova: Tooling Pull Requests automation moved this from 🐣 New PR / Untriaged to ✅ Approved, waiting for Merge Apr 23, 2019
@raphinesse
Copy link
Contributor

In case you know where that string is thrown, it would be great if you could create a PR to properly throw an Error instead.

Throwing objects other than Errors should be avoided since they provide no stack traces.

@raphinesse raphinesse merged commit f763776 into apache:master Apr 23, 2019
Apache Cordova: Tooling Pull Requests automation moved this from ✅ Approved, waiting for Merge to 🏆 Merged, waiting for Release Apr 23, 2019
@piotr-cz
Copy link
Contributor Author

@raphinesse:
It's coming from cordova-ios > create comand.
Most promises in that library are rejected with strings instead of CordovaError

Also in cordova-android: bin/templates/cordova/lib/run.js

@piotr-cz piotr-cz deleted the patch-1 branch April 23, 2019 11:34
@raphinesse
Copy link
Contributor

@piotr-cz Thanks for the information!

@piotr-cz
Copy link
Contributor Author

Sure, I just don't feel comfortable enough yet in cordova internals to create PRs for these packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Apache Cordova: Tooling Pull Requests
🏆 Merged, waiting for Release
Development

Successfully merging this pull request may close these issues.

None yet

2 participants