checks.cpp 814 B

12345678910111213141516171819202122232425262728293031
  1. #include <util/generic/string.h>
  2. #include <util/string/type.h>
  3. bool CheckExceptionMessage(const char* msg, TString& err) {
  4. static const char* badMsg[] = {
  5. // Операция успешно завершена [cp1251]
  6. "\xce\xef\xe5\xf0\xe0\xf6\xe8\xff\x20\xf3\xf1\xef\xe5\xf8\xed\xee\x20\xe7\xe0\xe2\xe5\xf0\xf8\xe5\xed\xe0",
  7. "The operation completed successfully",
  8. "No error"};
  9. err.clear();
  10. if (msg == nullptr) {
  11. err = "Error message is null";
  12. return false;
  13. }
  14. if (IsSpace(msg)) {
  15. err = "Error message is empty";
  16. return false;
  17. }
  18. for (auto& i : badMsg) {
  19. if (strstr(msg, i) != nullptr) {
  20. err = "Invalid error message: " + TString(msg);
  21. return false;
  22. }
  23. }
  24. return true;
  25. }