Skip to content

fix(@angular-devkit/schematics): throw `InvalidCollectionJsonExceptio… #11841

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

Merged
merged 1 commit into from
Sep 6, 2018
Merged

fix(@angular-devkit/schematics): throw `InvalidCollectionJsonExceptio… #11841

merged 1 commit into from
Sep 6, 2018

Conversation

alan-agius4
Copy link
Collaborator

throw InvalidCollectionJsonException when collection file is invalid

Closes #11818

Not quite sure, how can I test this, since I cannot use the node-modules-test-engine-host

@@ -102,7 +102,11 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
return collectionPath;
}
} catch (e) {
if (!(e instanceof FileDoesNotExistException)) {
throw new InvalidCollectionJsonException(name, collectionPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just rethrow the error instead? The sub error can be a JSON error which contains more information (line and character), or another error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I initially was gonna do did that, the only drawback was the in the error there won’t be information about which files cause the JSON error.

An alternative would be that InvalidCollectionJsonException would accept another parameter, and eventually if error.message is present it will be concatinated with original message that InvalidCollectionJsonException is showing to the user.

What do yo think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Something similar to this error #11861 with no context of which file is the problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think either solution would be better:

  1. An alternative would be that InvalidCollectionJsonException would accept another parameter of type InvalidJsonException and transfer over the info, or
  2. A separate new InvalidJsonFileException which takes a path and the json exception.

I'm fine with either. I have a slight preference to 1.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also prefer for the first option. I have pushed an updated. When you said transfer over the info I was not sure if you were referring the error message or stack or both. For the time being I did the message.

@alan-agius4
Copy link
Collaborator Author

@hansl, can you re-review this please? Thanks.

@ngbot
Copy link

ngbot bot commented Aug 29, 2018

Hi @alan-agius4! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Aug 31, 2018
@@ -91,16 +103,16 @@ export class SchematicNameCollisionException extends BaseException {
* all other EngineHost provided by the tooling part of the Schematics library.
*/
export abstract class FileSystemEngineHostBase implements
EngineHost<FileSystemCollectionDescription, FileSystemSchematicDescription> {
EngineHost<FileSystemCollectionDescription, FileSystemSchematicDescription> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why all the style changes? Your PR should only include code you changed.

Copy link
Collaborator Author

@alan-agius4 alan-agius4 Sep 1, 2018

Choose a reason for hiding this comment

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

Yeah agreed, must have done auto format when fixing the rebase conflict.

Will fix this later

@googlebot
Copy link

☹️ Sorry, but only Googlers may change the label cla: yes.

@alexeagle alexeagle merged commit 54f7ea2 into angular:master Sep 6, 2018
@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 Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dev-kit/schematics: collection.json incorrectly formatted error swallowed
4 participants