-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: global namespace resolution, handler exception semantics, record property init, unit test alignment #30
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
Changes from all commits
66e77b1
987b693
ec5ed75
4633bfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||
| using IssueManager.Api.Data; | ||||||||||||||
| using IssueManager.Api.Handlers; | ||||||||||||||
| using IssueManager.Shared.Validators; | ||||||||||||||
| using global::Shared.Validators; | ||||||||||||||
| using IssueManager.Shared.Domain.DTOs; | ||||||||||||||
| using static IssueManager.Api.Handlers.GetIssueHandler; | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -46,6 +47,18 @@ | |||||||||||||
| .ToDictionary(g => g.Key, g => g.Select(e => e.ErrorMessage).ToArray()); | ||||||||||||||
| await context.Response.WriteAsJsonAsync(new { title = "Validation failed", errors }); | ||||||||||||||
| } | ||||||||||||||
| else if (ex is global::Shared.Exceptions.NotFoundException notFoundEx) | ||||||||||||||
| { | ||||||||||||||
| context.Response.StatusCode = StatusCodes.Status404NotFound; | ||||||||||||||
| context.Response.ContentType = "application/problem+json"; | ||||||||||||||
| await context.Response.WriteAsJsonAsync(new { title = "Not Found", detail = notFoundEx.Message }); | ||||||||||||||
| } | ||||||||||||||
| else if (ex is global::Shared.Exceptions.ConflictException conflictEx) | ||||||||||||||
| { | ||||||||||||||
| context.Response.StatusCode = StatusCodes.Status409Conflict; | ||||||||||||||
| context.Response.ContentType = "application/problem+json"; | ||||||||||||||
| await context.Response.WriteAsJsonAsync(new { title = "Conflict", detail = conflictEx.Message }); | ||||||||||||||
| } | ||||||||||||||
| else | ||||||||||||||
| { | ||||||||||||||
| context.Response.StatusCode = StatusCodes.Status500InternalServerError; | ||||||||||||||
|
|
@@ -56,7 +69,7 @@ | |||||||||||||
| app.MapOpenApi(); | ||||||||||||||
|
|
||||||||||||||
| // Issue API Endpoints | ||||||||||||||
| var issuesApi = app.MapGroup("/api/v1/issues") | ||||||||||||||
|
Check warning on line 72 in src/Api/Program.cs
|
||||||||||||||
| .WithTags("Issues") | ||||||||||||||
| .WithOpenApi(); | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -100,20 +113,21 @@ | |||||||||||||
| { | ||||||||||||||
| var commandWithId = command with { Id = id }; | ||||||||||||||
| var result = await handler.Handle(commandWithId); | ||||||||||||||
|
||||||||||||||
| var result = await handler.Handle(commandWithId); | |
| var result = await handler.Handle(commandWithId); | |
| if (result is null) | |
| { | |
| return Results.NotFound(); | |
| } |
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.
Handlenow returnsTask<Issue>(non-nullable), but the repository contract (IIssueRepository.UpdateAsync) returnsTask<Issue?>. Since the implementation returnsnullwhenModifiedCount == 0, this handler can still end up returningnulldespite the signature. Consider either makingUpdateAsyncreturn a non-nullIssuewhen the record exists, or keep the handler return type nullable / throw when the update result is null.