Skip to content

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

Merged
alexeagle merged 1 commit intoangular:masterfrom
alan-agius4:fix_schematics_collection_error
Sep 6, 2018
Merged

fix(@angular-devkit/schematics): throw `InvalidCollectionJsonExceptio…#11841
alexeagle merged 1 commit intoangular:masterfrom
alan-agius4:fix_schematics_collection_error

Conversation

@alan-agius4
Copy link
Copy Markdown
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

}
} catch (e) {
if (!(e instanceof FileDoesNotExistException)) {
throw new InvalidCollectionJsonException(name, collectionPath);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

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

@ngbot
Copy link
Copy Markdown

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
*/
export abstract class FileSystemEngineHostBase implements
EngineHost<FileSystemCollectionDescription, FileSystemSchematicDescription> {
EngineHost<FileSystemCollectionDescription, FileSystemSchematicDescription> {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

☹️ 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
Copy Markdown

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