Summary of Defect:
Attempting to retrieve a Trainer that does not exist returns incorrect HTTP error code
Expected Result:
HTTP status code 404 - Not Found
Actual Result:
HTTP status code 500 - Server error
System.Exception: The trainer you're looking for is null
at TraineeTracker.Services.TrainerService.GetTrainer(Int32 id) in F:\Downloads\TraineeTracker\TraineeTracker\TraineeTracker\Services\TrainerService.cs:line 36
at TraineeTracker.Controllers.API.TrainersController.GetTrainer(Int32 id) in F:\Downloads\TraineeTracker\TraineeTracker\TraineeTracker\Controllers\API\TrainersController.cs:line 38
at lambda_method135(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker...........
...........
Defect Description: (Hint: Steps to Reproduce)
Attempting to retrieve a Trainer that does not exist should return a 404 error code, indicating to the client that the entity (Trainer) does not exist. API should not indicate that a (generic) error occured on the server. Additionally, details of the exception are returned in the response. The error message is sufficient
Steps to reproduce
With server running locally on localhost port 7234
Summary of Defect: Attempting to retrieve a Trainer that does not exist returns incorrect HTTP error code
Expected Result: HTTP status code 404 - Not Found
Actual Result: HTTP status code 500 - Server error
System.Exception: The trainer you're looking for is null at TraineeTracker.Services.TrainerService.GetTrainer(Int32 id) in F:\Downloads\TraineeTracker\TraineeTracker\TraineeTracker\Services\TrainerService.cs:line 36 at TraineeTracker.Controllers.API.TrainersController.GetTrainer(Int32 id) in F:\Downloads\TraineeTracker\TraineeTracker\TraineeTracker\Controllers\API\TrainersController.cs:line 38 at lambda_method135(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker........... ...........
Defect Description: (Hint: Steps to Reproduce) Attempting to retrieve a Trainer that does not exist should return a 404 error code, indicating to the client that the entity (Trainer) does not exist. API should not indicate that a (generic) error occured on the server. Additionally, details of the exception are returned in the response. The error message is sufficient
Steps to reproduce With server running locally on localhost port 7234
In Postman: GET https://localhost:7234/api/Trainers/-999 View the response.
Further Comment: