-
Notifications
You must be signed in to change notification settings - Fork 12k
feature(config): improved error message for invalid angular-cli.json #2565
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
Conversation
#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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you throw a new InvalidConfigError
with the message both here and below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, how silly of me.. Fixed, let's see if it passes this time :)
Oh I see, you wanted to say #2526! I'll edit your comment. |
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).
Seems so. I'll merge soon. |
…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).
…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).
…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).
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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