SES-128 Fix Error response

This commit is contained in:
Karol Górzyński 2021-01-08 17:38:05 +01:00
parent 20d81f4bf5
commit 68ab7ceebd

View File

@ -25,14 +25,19 @@ namespace SessionCompanion.Controllers
[HttpGet("getAllWeapons")]
public async Task<Either<List<WeaponViewModel>, ErrorResponse>> GetWeapons()
{
var weapons = _service.Get().ToList();
if (!weapons.Any())
try
{
var weapons = _service.Get().ToList();
return weapons;
}
catch (Exception e)
{
return new ErrorResponse()
{
StatusCode = 204,
Message = "No weapons in database"
Message = e.Message
};
return weapons;
}
}
}
}