Skip to content

User errors shouldn't print stack traces #12165

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

Closed
alexeagle opened this issue Sep 5, 2018 · 4 comments · Fixed by #22779
Closed

User errors shouldn't print stack traces #12165

alexeagle opened this issue Sep 5, 2018 · 4 comments · Fixed by #22779
Assignees
Labels
area: @angular-devkit/schematics feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Milestone

Comments

@alexeagle
Copy link
Contributor

From @dansanderson on June 14, 2017 18:18

When the CLI is reporting an error that represents invalid options or inputs, it should not print a stack trace. It should still return a shell status code.

Some schematics are throwing an Error for these messages, but we need to differentiate between user errors and internal tool errors to hide diagnostic info in the first case (unless, perhaps, a --debug tool flag is included).

Copied from original issue: angular/devkit#8

@alexeagle alexeagle added comp: angular-devkit/schematics feature Issue that requests a new feature labels Sep 5, 2018
@ngbot ngbot bot modified the milestone: Backlog Sep 5, 2018
@alexeagle
Copy link
Contributor Author

From @paisanousa on January 22, 2018 3:39

The following identifies specific returned errors where stack traces appear:

schematics command-line errors cluttered with stack traces

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request

Area

- [X] devkit
- [ ] schematics

Versions

:~$ node -v
v9.4.0

:~$ npm -v
5.6.0

Globals:
:~$ npm list --depth=0 -g
/home/dennis/.nvm/versions/node/v9.4.0/lib
├── @angular-devkit/[email protected]
├── @angular-devkit/[email protected]
├── @angular-devkit/[email protected]
└── [email protected]

:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

Repro steps

  • Step 1 - Verify "schematics" available at command line:
:~$ schematics
schematics [CollectionName:]SchematicName [options, ...]

By default, if the collection name is not specified, use the internal collection provided
by the Schematics CLI.

Options:
    --debug             Debug mode. This is true by default if the collection is a relative
                        path (in that case, turn off with --debug=false).
    --dry-run           Do not output anything, but instead just show what actions would be
                        performed. Default to true if debug is also true.
    --force             Force overwriting files that would otherwise be an error.
    --list-schematics   List all schematics from the collection, by name.
    --verbose           Show more information.

    --help              Show this message.

Any additional option is passed to the Schematics depending on
  • Step 2 - Verify properly-formatted command creates new schematic:
:~$ schematics @schematics/schematics:schematic --name demo
CREATE /demo/README.md (635 bytes)
CREATE /demo/.gitignore (191 bytes)
CREATE /demo/package.json (523 bytes)
CREATE /demo/src/collection.json (1698 bytes)
CREATE /demo/src/my-full-schematic/index.ts (2455 bytes)
CREATE /demo/src/my-full-schematic/index_spec.ts (864 bytes)
CREATE /demo/src/my-full-schematic/schema.json (306 bytes)
CREATE /demo/src/my-other-schematic/index.ts (1346 bytes)
CREATE /demo/src/my-other-schematic/index_spec.ts (509 bytes)
CREATE /demo/src/my-schematic/index.ts (1458 bytes)
CREATE /demo/src/my-schematic/index_spec.ts (482 bytes)
CREATE /demo/tsconfig.json (631 bytes)
CREATE /demo/src/my-full-schematic/files/test2 (127 bytes)
CREATE /demo/src/my-full-schematic/files/test__INDEX__ (29 bytes)
  • Step 3 - Mangle "schematics" command to create error conditions:
Create various "not found" conditions to observe error output:
:~$ schematics @schemMANGLE/schematics:schematic --name demo
:~$ schematics @schematics/schemMANGLE:schematic --name demo
:~$ schematics @schematics/schematics:schemMANGLE --name demo

Each command fails as expected. However, the error messages include 
stack traces which might lead one to believe the CLI has failed rather 
than properly reporting user errors. The output of the three attempts 
is recorded in the next section.

The log given by the failure

:~$ schematics @schemMANGLE/schematics:schematic --name demo
/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/core/node/resolve.js:140
    throw new ModuleNotFoundException(x, basePath);
    ^

Error: Could not find module "@schemMANGLE/schematics" from "/home/dennis".
    at Object.resolve (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/core/node/resolve.js:140:11)
    at NodeModulesEngineHost._resolvePackageJson (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:22:21)
    at NodeModulesEngineHost._resolveCollectionPath (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:43:36)
    at NodeModulesEngineHost.createCollectionDescription (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:102:27)
    at SchematicEngine.createCollection (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:46:40)
    at Object.<anonymous> (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/bin/schematics.js:96:27)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
:~$ schematics @schematics/schemMANGLE:schematic --name demo
/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/core/node/resolve.js:140
    throw new ModuleNotFoundException(x, basePath);
    ^

Error: Could not find module "@schematics/schemMANGLE" from "/home/dennis".
    at Object.resolve (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/core/node/resolve.js:140:11)
    at NodeModulesEngineHost._resolvePackageJson (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:22:21)
    at NodeModulesEngineHost._resolveCollectionPath (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:43:36)
    at NodeModulesEngineHost.createCollectionDescription (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:102:27)
    at SchematicEngine.createCollection (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:46:40)
    at Object.<anonymous> (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/bin/schematics.js:96:27)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
:~$ schematics @schematics/schematics:schemMANGLE --name demo
/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:134
            throw new schematics_1.UnknownSchematicException(name, collection);
            ^

Error: Schematic "schemMANGLE" not found in collection "@schematics/schematics".
    at NodeModulesEngineHost.createSchematicDescription (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:134:19)
    at SchematicEngine.createSchematic (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/engine/engine.js:81:40)
    at CollectionImpl.createSchematic (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/node_modules/@angular-devkit/schematics/src/engine/collection.js:11:29)
    at Object.<anonymous> (/home/dennis/.nvm/versions/node/v9.4.0/lib/node_modules/@angular-devkit/schematics-cli/bin/schematics.js:109:30)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)

Desired functionality

The expected results would be concise error messages with no stack traces. The messages might include information pointing the user to the correct command format and/or usage:

Similar to this error message: 
:~$ schematics @schematics/schematics:schematic --namMANGLE demo
Schematic input does not validate against the Schema: {}
Errors:
   should have required property 'name'

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 1, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@ngbot ngbot bot modified the milestones: Backlog, needsTriage Feb 1, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors and removed feature: votes required Feature request which is currently still in the voting phase labels Feb 21, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular-devkit/schematics feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants