Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private static async Task<int> ExecuteAsync(
{
ICreateClientCommandMutation_CreateClient_Errors_ApiNotFoundError err => err.Message,
ICreateClientCommandMutation_CreateClient_Errors_UnauthorizedOperation err => err.Message,
ICreateClientCommandMutation_CreateClient_Errors_DuplicateNameError => Messages.DuplicateName(name, "Client"),
IError err => Messages.UnexpectedMutationError(err),
_ => Messages.UnexpectedMutationError()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private static async Task<int> ExecuteAsync(
{
IApiNotFoundError err => err.Message,
IUnauthorizedOperation err => err.Message,
IDuplicateNameError => Messages.DuplicateName(name, "MCP Feature Collection"),
IError err => Messages.UnexpectedMutationError(err),
_ => Messages.UnexpectedMutationError()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private static async Task<int> ExecuteAsync(
{
IApiNotFoundError err => err.Message,
IUnauthorizedOperation err => err.Message,
IDuplicateNameError => Messages.DuplicateName(name, "OpenAPI Collection"),
IError err => Messages.UnexpectedMutationError(err),
_ => Messages.UnexpectedMutationError()
};
Expand Down
3 changes: 3 additions & 0 deletions src/Nitro/CommandLine/src/CommandLine/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public static string UnexpectedMutationError()
public static string UnexpectedMutationError(IError error)
=> $"Unexpected mutation error: {error.Message}";

public static string DuplicateName(string name, string entity)
=> $"The name '{name.EscapeMarkup()}' is already in use by another {entity}.";

public static string SchemaFileDoesNotExist(string path) => $"Schema file '{path}' does not exist.";

public static string SchemaSettingsFileDoesNotExist(string path) => $"Schema settings file '{path}' does not exist.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,17 @@ public static TheoryData<ICreateClientCommandMutation_CreateClient_Errors, strin
var unauthorized = new Mock<ICreateClientCommandMutation_CreateClient_Errors_UnauthorizedOperation>(MockBehavior.Strict);
unauthorized.As<IUnauthorizedOperation>().SetupGet(x => x.Message).Returns("Unauthorized operation.");

var duplicateName = new Mock<ICreateClientCommandMutation_CreateClient_Errors_DuplicateNameError>(MockBehavior.Strict);
duplicateName.As<IDuplicateNameError>().SetupGet(x => x.Message).Returns("Name already in use.");

var genericError = new Mock<ICreateClientCommandMutation_CreateClient_Errors>(MockBehavior.Strict);
genericError.As<IError>().SetupGet(x => x.Message).Returns("something bad happened");

return new()
{
{ apiNotFound.Object, "The API was not found." },
{ unauthorized.Object, "Unauthorized operation." },
{ duplicateName.Object, "The name 'web-client' is already in use by another Client." },
{ genericError.Object, "Unexpected mutation error: something bad happened" }
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public static TheoryData<ICreateMcpFeatureCollectionCommandMutation_CreateMcpFea
new CreateMcpFeatureCollectionCommandMutation_CreateMcpFeatureCollection_Errors_UnauthorizedOperation(
"Not authorized", "UnauthorizedOperation"),
"Not authorized"
},
{
new CreateMcpFeatureCollectionCommandMutation_CreateMcpFeatureCollection_Errors_DuplicateNameError(
"Name already in use", "DuplicateNameError"),
"The name 'my-mcp' is already in use by another MCP Feature Collection."
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ API not found
"""
Not authorized
"""
},
{
new CreateOpenApiCollectionCommandMutation_CreateOpenApiCollection_Errors_DuplicateNameError(
"Name already in use", "DuplicateNameError"),
"""
The name 'my-openapi' is already in use by another OpenAPI Collection.
"""
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mutation CreateClientCommandMutation($input: CreateClientInput!) {
...Error
...ApiNotFoundError
...UnauthorizedOperation
...DuplicateNameError
}
}
}
Expand Down
Loading
Loading