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

Make error message more clear for duplicate shapes #324

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

mtdowling
Copy link
Member

This commit updates model loaders to fail at the point that a duplicate
shape definition is detected in a file. This results in clearer error
messages when a shape is defined with the same name, particularly if one
conflicting shape supports members while the other does not. Previously,
in this case, a cryptic error message would be returned stating that a
member cannot be added to a builder:

Member `example.foo#Bar$Baz` cannot be added to software.amazon.smithy.model.shapes.OperationShape$Builder

This now becomes:

[ERROR] -: Duplicate shape definition for `example.foo#Bar$Baz` found at `/path/file.smithy [3, 1]` and `/path/file.smithy [5, 1]` | Model

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This commit updates model loaders to fail at the point that a duplicate
shape definition is detected in a file. This results in clearer error
messages when a shape is defined with the same name, particularly if one
conflicting shape supports members while the other does not. Previously,
in this case, a cryptic error message would be returned stating that a
member cannot be added to a builder:

    Member `example.foo#Bar$Baz` cannot be added to
    software.amazon.smithy.model.shapes.OperationShape$Builder

This now becomes:

    [ERROR] -: Duplicate shape definition for
    `example.foo#Bar$Baz` found at
    `/path/file.smithy [3, 1]` and `/path/file.smithy [5, 1]` | Model
@mtdowling mtdowling requested a review from kstich March 26, 2020 02:31
@@ -54,28 +53,18 @@ private ModelLoader() {}
* @throws SourceException if there is an error reading from the contents.
*/
static boolean load(String filename, Supplier<InputStream> contentSupplier, LoaderVisitor visitor) {
try {
Copy link
Member Author

Choose a reason for hiding this comment

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

This try/catch wasn't necessary

@mtdowling mtdowling merged commit 28a3493 into 0.10 Mar 26, 2020
@mtdowling mtdowling deleted the fix-duplicate-shape-error branch March 27, 2020 17:41
@kstich kstich mentioned this pull request Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants