SES-128 Fix Error response
This commit is contained in:
parent
20d81f4bf5
commit
68ab7ceebd
@ -24,15 +24,20 @@ namespace SessionCompanion.Controllers
|
||||
/// <returns>Lista wszystkich broni w bazie danych</returns>
|
||||
[HttpGet("getAllWeapons")]
|
||||
public async Task<Either<List<WeaponViewModel>, ErrorResponse>> GetWeapons()
|
||||
{
|
||||
try
|
||||
{
|
||||
var weapons = _service.Get().ToList();
|
||||
if (!weapons.Any())
|
||||
return weapons;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ErrorResponse()
|
||||
{
|
||||
StatusCode = 204,
|
||||
Message = "No weapons in database"
|
||||
Message = e.Message
|
||||
};
|
||||
return weapons;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user