Browse Source

listmanager_dummy - Separate DoesNotExistException into ListDoesNotExistException and MemberDoesNotExistException

LIB-11
heck 6 months ago
parent
commit
4ab61fccdb
3 changed files with 18 additions and 14 deletions
  1. +6
    -6
      src/listmanager_dummy.cc
  2. +6
    -2
      src/listmanager_dummy.hh
  3. +6
    -6
      test/test_listmanager_dummy.cc

+ 6
- 6
src/listmanager_dummy.cc View File

@ -122,7 +122,7 @@ namespace pEp {
{
pEpLogClass("list_delete(addr_list: \"" + addr_list + "\")");
if (!list_exists(addr_list)) {
DoesNotExistException e{ "list_delete(addr_list: \"" + addr_list +
ListDoesNotExistException e{ "list_delete(addr_list: \"" + addr_list +
"\") - List does not exist" };
throw e;
}
@ -144,7 +144,7 @@ namespace pEp {
pEpLogClass(
"member_add(addr_list: \"" + addr_list + "\", addr_member: \"" + addr_member + "\")");
if (!list_exists(addr_list)) {
DoesNotExistException e{ "member_add(addr_list: \"" + addr_list + "\", addr_member: \"" +
ListDoesNotExistException e{ "member_add(addr_list: \"" + addr_list + "\", addr_member: \"" +
addr_member + "\") - list does not exist" };
throw e;
}
@ -172,14 +172,14 @@ namespace pEp {
pEpLogClass(
"member_remove(addr_list: \"" + addr_list + "\", addr_member: '\"" + addr_member + "\")");
if (!list_exists(addr_list)) {
DoesNotExistException e{ "member_remove(addr_list: \"" + addr_list +
ListDoesNotExistException e{ "member_remove(addr_list: \"" + addr_list +
"\", addr_member: '\"" + addr_member +
"\") - list does not exist" };
throw e;
}
if (!member_exists(addr_list, addr_member)) {
DoesNotExistException e{ "member_remove(addr_list: \"" + addr_list +
MemberDoesNotExistException e{ "member_remove(addr_list: \"" + addr_list +
"\", addr_member: '\"" + addr_member +
"\") - member does not exist" };
throw e;
@ -226,7 +226,7 @@ namespace pEp {
{
pEpLogClass("moderator(list_address:\"" + addr_list + "\")");
if (!list_exists(addr_list)) {
DoesNotExistException e{ "moderator(list_address:\"" + addr_list +
ListDoesNotExistException e{ "moderator(list_address:\"" + addr_list +
"\") - List does not exist" };
throw e;
}
@ -260,7 +260,7 @@ namespace pEp {
{
pEpLogClass("members(list_address:\"" + addr_list + "\")");
if (!list_exists(addr_list)) {
DoesNotExistException e{ "members(list_address:\"" + addr_list +
ListDoesNotExistException e{ "members(list_address:\"" + addr_list +
"\") - List does not exist" };
throw e;
}


+ 6
- 2
src/listmanager_dummy.hh View File

@ -46,9 +46,13 @@ namespace pEp {
public:
DBException(const std::string& string) : runtime_error(string) {}
};
class DoesNotExistException : public std::runtime_error {
class ListDoesNotExistException : public std::runtime_error {
public:
DoesNotExistException(const std::string& string) : runtime_error(string) {}
ListDoesNotExistException(const std::string& string) : runtime_error(string) {}
};
class MemberDoesNotExistException : public std::runtime_error {
public:
MemberDoesNotExistException(const std::string& string) : runtime_error(string) {}
};
class AlreadyExistsException : public std::runtime_error {
public:


+ 6
- 6
test/test_listmanager_dummy.cc View File

@ -203,7 +203,7 @@ int main(int argc, char* argv[])
try {
lmd.list_delete("does_not_exist_for_sure");
assert(false);
} catch (const DoesNotExistException& e) {
} catch (const ListDoesNotExistException& e) {
log(nested_exception_to_string(e));
} catch (...) {
assert(false);
@ -233,7 +233,7 @@ int main(int argc, char* argv[])
try {
lmd.member_add("does_not_exist_for_sure", model.lists.at(0).members.at(0));
assert(false);
} catch (const DoesNotExistException& e) {
} catch (const ListDoesNotExistException& e) {
log(nested_exception_to_string(e));
} catch (...) {
assert(false);
@ -249,7 +249,7 @@ int main(int argc, char* argv[])
try {
lmd.member_remove(model.lists.at(0).addr, "does_not_exist_for_sure");
assert(false);
} catch (const DoesNotExistException& e) {
} catch (const MemberDoesNotExistException& e) {
log(nested_exception_to_string(e));
} catch (...) {
assert(false);
@ -263,7 +263,7 @@ int main(int argc, char* argv[])
try {
lmd.member_remove("does_not_exist_for_sure", model.lists.at(0).members.at(0));
assert(false);
} catch (const DoesNotExistException& e) {
} catch (const ListDoesNotExistException& e) {
log(nested_exception_to_string(e));
} catch (...) {
assert(false);
@ -279,7 +279,7 @@ int main(int argc, char* argv[])
try {
lmd.moderator("does_not_exist_for_sure");
assert(false);
} catch (const DoesNotExistException& e) {
} catch (const ListDoesNotExistException& e) {
log(nested_exception_to_string(e));
} catch (...) {
assert(false);
@ -295,7 +295,7 @@ int main(int argc, char* argv[])
try {
lmd.members("does_not_exist_for_sure");
assert(false);
} catch (const DoesNotExistException& e) {
} catch (const ListDoesNotExistException& e) {
log(nested_exception_to_string(e));
} catch (...) {
assert(false);


Loading…
Cancel
Save