Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Restructure error messaging #484

Merged
merged 6 commits into from
Nov 16, 2015

Conversation

Mitko-Kerezov
Copy link
Contributor

References #300626

Introduces a new messaging service which reads messages from given .json files. There is one such file placed in this library and is loaded by default. Its keys can be overriden by providing other, client-specific .json files containing the same keys but with a different value.

In order to achieve autocompletion on referencing these error messages a new generation command is introduced - dev-generate-messages. It produces a .d.ts interface, as well as a .ts implementation file, which contain all keys from all provided json files as properties. If run as-is it generates files for the client from which the command is launched. If --default option is provided generates messages in common lib only.

In order to apply this change I've moved some of the code-generation logic related to AppBuilder-CLI's swagger here. The only change other than physically moving these files is the introduction of a non-mandatory field - endingCharacter?: string; - needed in order to generate Typescript properties more aesthetically

Sample usage of this whole effort can be seen in devices-services.ts file in this PR.

@justcodebuilduser
Copy link

💔

1 similar comment
@justcodebuilduser
Copy link

💔

@Mitko-Kerezov Mitko-Kerezov force-pushed the kerezov/restructure-error-messaging branch from ce21ae0 to 6a5aada Compare October 13, 2015 09:31
@justcodebuilduser
Copy link

❤️

@Mitko-Kerezov Mitko-Kerezov force-pushed the kerezov/restructure-error-messaging branch from 6a5aada to 2eb9130 Compare October 13, 2015 09:34
@justcodebuilduser
Copy link

❤️

if(block.opener) {
content += this.getIndentation(indentSize);
content += SwaggerCodePrinter.END_BLOCK_CHAR;
content += block.endingCharacter ? block.endingCharacter : '';
Copy link
Contributor

Choose a reason for hiding this comment

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

block.endingCharacter || ''

Dimitar Kerezov added 5 commits November 13, 2015 16:45
Used for extracting messages out of given .json files. If given a key be it simple (Some_error_message) or complex (iOS.iTunes.Connection_Refused_Error) should return a message if one is found in any given file. If no value is found returns the key itself. Given .json files are prioritized - that is to say if a key is found in the first file it is immediately returned. That way messages can be overriden - for example appbuilder.messages.json may override keys from common.messages.json
That way an interface (IMessages) and an implementation file is generated which can be used for autocompletion when accessing JSON-predefined error messages.
Includes a bit of refactoring - extracting some classes from swagger into common.
Usage of the new messages service can be seen in `devices-services` class
I'm committing the first draft of messages.d.ts and messages.ts which will hopefully grow in the future.
Covering all the basic scenarios.
@Mitko-Kerezov Mitko-Kerezov force-pushed the kerezov/restructure-error-messaging branch from 2eb9130 to cf8b7c7 Compare November 13, 2015 15:45
@justcodebuilduser
Copy link

💔

@justcodebuilduser
Copy link

❤️

@Mitko-Kerezov
Copy link
Contributor Author

Addressed all issues, ping @teobugslayer @Fatme and @rosen-vladimirov for a second review

@rosen-vladimirov
Copy link
Collaborator

👍

Mitko-Kerezov added a commit that referenced this pull request Nov 16, 2015
@Mitko-Kerezov Mitko-Kerezov merged commit a756232 into master Nov 16, 2015
@Mitko-Kerezov Mitko-Kerezov deleted the kerezov/restructure-error-messaging branch November 16, 2015 14:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants