From b64e56223516a113130fb707fdf23a87499449d8 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Sun, 27 Jun 2021 12:47:20 -0700 Subject: [PATCH] changed error status --- include/error_responses.hpp | 12 ++++++------ src/bank.cpp | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/error_responses.hpp b/include/error_responses.hpp index 6c4de41..4eefc19 100644 --- a/include/error_responses.hpp +++ b/include/error_responses.hpp @@ -1,10 +1,10 @@ #pragma once enum ErrorResponse { - UserNotFound = -1, - WrongPassword = -2, - InvalidRequest = -3, - NameTooLong = -4, - UserAlreadyExists = -5, - InsufficientFunds = -6, + UserNotFound = -1, //404 + WrongPassword = -2, //401 + InvalidRequest = -3, //400 + NameTooLong = -4, //400? + UserAlreadyExists = -5, //409 + InsufficientFunds = -6, //402? }; \ No newline at end of file diff --git a/src/bank.cpp b/src/bank.cpp index 59f99ce..87a529a 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -81,7 +81,7 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam //if A can afford it if (a.balance < amount) { - state = {k204NoContent, "Sender has insufficient funds"}; + state = {k402PaymentRequired, "Sender has insufficient funds"}; } else { @@ -104,10 +104,10 @@ BankResponse Bank::SendFunds(const std::string &a_name, const std::string &b_nam { std::shared_lock lock{send_funds_l}; 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) { - state = {k204NoContent, "Sender has insufficient funds"}; + state = {k402PaymentRequired, "Sender has insufficient funds"}; } else {