Skip to content

dev-kit/schematics: collection.json incorrectly formatted error swallowed #11818

Closed
@cgatian

Description

@cgatian

Bug Report or Feature Request (mark with an x)

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

If the collection.json is not formatted in proper JSON schematics pukes and the error message is misleading. I understand the root cause was user error. However, the error message returned lead me down a deep path of questioning how the schematic was being resolved. Only when I started debugging the dev-kit/schematic code, was I able to determine the root of the issue.

Repro steps

When executing a schematic if the collection.json is not json formatted (in my case I was missing a brace) and error occurs.

The log given by the failure

Collection "@company/package" cannot be resolved.
Error: Collection "@company/package" cannot be resolved.
    at NodeModulesEngineHost._resolveCollectionPath (C:\test-schematic\node_modules\@angular-devkit\schematics\tools\node-module-engine-host.js:88:15)
    at NodeModulesEngineHost.createCollectionDescription (C:\test-schematic\schem\node_modules\@angular-devkit\schematics\tools\file-system-engine-host-base.js:106:27)
....

Desired functionality

Add a better error description would be useful, or do not swallow error.

Mention any other details that might be useful

Code located at ln 104 in node-module-engine-host.ts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions