kenny95h / TraineeTrackerTestFramework

1 stars 2 forks source link

API 9.1 Read a Trainer #98

Open kenny95h opened 2 years ago

kenny95h commented 2 years ago

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:

yusufkabir commented 1 year ago

DEFECT - Confirmed that https://localhost:7234/api/Trainers/-999 RETURNS 500 Internal Server Error (Throw null exception)