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

feature(config): improved error message for invalid angular-cli.json #2565

Merged
merged 1 commit into from Oct 10, 2016

Conversation

@RoopeHakulinen
Copy link
Contributor

RoopeHakulinen commented Oct 7, 2016

Earlier invalid angular-cli.json yielded only "Error". Now it prints something like:

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error:
SyntaxError: Unexpected token s in JSON at position 2

Almost the same message is now also used for the other configuration files (schema and other).

This fixes #2526

@filipesilva
Copy link
Member

filipesilva commented Oct 10, 2016

#2536 is about npm issues so I don't think it'd help. It's a fine idea though, to improve these messages.

@@ -80,10 +80,16 @@ export class CliConfig<JsonType> {

try {
content = JSON.parse(configContent);
} catch (err) {
throw 'Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid'

This comment has been minimized.

Copy link
@filipesilva

filipesilva Oct 10, 2016

Member

Can you throw a new InvalidConfigError with the message both here and below?

This comment has been minimized.

Copy link
@RoopeHakulinen

RoopeHakulinen Oct 10, 2016

Author Contributor

Using the class currently declared as InvalidConfigError always just prints "Error", no matter what you pass to it. For that reason I fixed it to use the way provided in this SO answer. Now it prints the error correctly. Also applied the same for another existing use of the InvalidConfigError class.

This comment has been minimized.

Copy link
@filipesilva

filipesilva Oct 10, 2016

Member

Awesome, that works for me. There's some CI errors now though, they seem related to compilation:

packages/angular-cli/models/config/config.ts(10,15): error TS7006: Parameter 'message' implicitly has an 'any' type.

Just a matter of adding constructor(message: string) { I believe.

This comment has been minimized.

Copy link
@RoopeHakulinen

RoopeHakulinen Oct 10, 2016

Author Contributor

Right, how silly of me.. Fixed, let's see if it passes this time :)

@filipesilva
Copy link
Member

filipesilva commented Oct 10, 2016

Oh I see, you wanted to say #2526! I'll edit your comment.

@RoopeHakulinen
Copy link
Contributor Author

RoopeHakulinen commented Oct 10, 2016

Yeah, #2526 is the correct one. Sorry for inconvenience.

Earlier invalid angular-cli.json yielded only "Error". Now it prints something like:

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error:
SyntaxError: Unexpected token s in JSON at position 2

Almost the same message is now also used for the other configuration files (schema and other).
@filipesilva
Copy link
Member

filipesilva commented Oct 10, 2016

Seems so. I'll merge soon.

@filipesilva filipesilva merged commit db73c0c into angular:master Oct 10, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@RoopeHakulinen RoopeHakulinen deleted the RoopeHakulinen:patch-1 branch Oct 10, 2016
JJayet added a commit to JJayet/angular-cli that referenced this pull request Oct 14, 2016
…ngular#2565)

Earlier invalid angular-cli.json yielded only "Error". Now it prints something like:

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error:
SyntaxError: Unexpected token s in JSON at position 2

Almost the same message is now also used for the other configuration files (schema and other).
Brocco added a commit that referenced this pull request Oct 19, 2016
…2565)

Earlier invalid angular-cli.json yielded only "Error". Now it prints something like:

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error:
SyntaxError: Unexpected token s in JSON at position 2

Almost the same message is now also used for the other configuration files (schema and other).
texel pushed a commit to splice/angular-cli that referenced this pull request Nov 3, 2016
…ngular#2565)

Earlier invalid angular-cli.json yielded only "Error". Now it prints something like:

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON. Error:
SyntaxError: Unexpected token s in JSON at position 2

Almost the same message is now also used for the other configuration files (schema and other).
@angular-automatic-lock-bot
Copy link

angular-automatic-lock-bot bot commented Sep 10, 2019

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 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.