changed error status

This commit is contained in:
EntireTwix 2021-06-27 12:47:20 -07:00
parent 749d20880f
commit b64e562235
2 changed files with 9 additions and 9 deletions

View file

@ -1,10 +1,10 @@
#pragma once #pragma once
enum ErrorResponse enum ErrorResponse
{ {
UserNotFound = -1, UserNotFound = -1, //404
WrongPassword = -2, WrongPassword = -2, //401
InvalidRequest = -3, InvalidRequest = -3, //400
NameTooLong = -4, NameTooLong = -4, //400?
UserAlreadyExists = -5, UserAlreadyExists = -5, //409
InsufficientFunds = -6, InsufficientFunds = -6, //402?
}; };

View file

@ -81,7 +81,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam
//if A can afford it //if A can afford it
if (a.balance < amount) if (a.balance < amount)
{ {
state = {k204NoContent, "Sender has insufficient funds"}; state = {k402PaymentRequired, "Sender has insufficient funds"};
} }
else else
{ {
@ -104,10 +104,10 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam
{ {
std::shared_lock<std::shared_mutex> lock{send_funds_l}; std::shared_lock<std::shared_mutex> lock{send_funds_l};
users.modify_if(a_name, [this, &state, amount](User &a) { users.modify_if(a_name, [this, &state, amount](User &a) {
//if A can afford it and A's password matches attempt //if A can afford it
if (a.balance < amount) if (a.balance < amount)
{ {
state = {k204NoContent, "Sender has insufficient funds"}; state = {k402PaymentRequired, "Sender has insufficient funds"};
} }
else else
{ {