Skip to content

Make error message more clear for duplicate shapes#324

Merged
mtdowling merged 1 commit into0.10from
fix-duplicate-shape-error
Mar 26, 2020
Merged

Make error message more clear for duplicate shapes#324
mtdowling merged 1 commit into0.10from
fix-duplicate-shape-error

Conversation

@mtdowling
Copy link
Copy Markdown
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
* @throws SourceException if there is an error reading from the contents.
*/
static boolean load(String filename, Supplier<InputStream> contentSupplier, LoaderVisitor visitor) {
try {
Copy link
Copy Markdown
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