Возврат читаемых ошибок.

This commit is contained in:
Vladimir N. Korotenko
2025-11-11 17:58:02 +03:00
parent 77b5a7c88d
commit f48621d6e0
8 changed files with 25 additions and 16 deletions

View File

@@ -33,6 +33,7 @@ int AccountStatus(const std::string address, const char* bkaddress, bool isDebug
string url("curl -s ");
url += address + "/api/v1/account/status?address=" + bkaddress ;
string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
string payload("");
@@ -63,6 +64,7 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
url.append("/api/v1/user/profile");
string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
@@ -121,6 +123,7 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu
url.append("/api/v1/user/profile");
string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
@@ -174,6 +177,7 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
url.append("/api/v1/deal/feedback/list");
string result = ExecCommand(url.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream;
@@ -209,15 +213,7 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
stream << " date: " << val["date"] << endl;
stream << " statustext: " << val["statustext"] << endl;
stream << " comments: " << val["comments"] << endl;
}
/*
- deal: ff5f337f-e0ab-4515-857f-3a0c8530dcd3
date: '2025-10-05T15:29:23'
statustext: positive
comments: positive comment about the deal
*/
}
}
stream << "------------Summary--------------" << endl;
stream << "total: " << size << endl;

View File

@@ -78,6 +78,7 @@ int AccountUpdate::ProcessUrl(std::string date, std::string signature, std::stri
data = Replace(data, string("{{URLS}}"), urlout);
string result = ExecCommand(data.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream;
@@ -106,6 +107,7 @@ int AccountUpdate::ProcessPgp(std::string date, std::string signature, std::stri
data = Replace(data, string("{{PGP}}"), pgp);
string result = ExecCommand(data.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream;
@@ -134,6 +136,7 @@ int AccountUpdate::ProcessBitmessage(std::string date, std::string signature, st
data = Replace(data, string("{{BTM}}"), btmsg);
string result = ExecCommand(data.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream;

View File

@@ -195,6 +195,7 @@ int Deals::Create() {
string result = ExecCommand(data.c_str());
if (result.length() == 0) return NoResponse("");
nlohmann::json jsonData = nlohmann::json::parse(result);
std::ostringstream stream;

View File

@@ -1,5 +1,6 @@
#include <string>
#include "common.hpp"
#include <iostream>
std::string Replace(std::string source, std::string from, std::string out) {
std::string res("");
size_t start = 0, stop = 0;
@@ -7,4 +8,10 @@ std::string Replace(std::string source, std::string from, std::string out) {
stop = from.length();
if (start >= 0 ) res = source.replace(start, stop, out);
return res;
}
}
int NoResponse(std::string mgs)
{
std::cout << "No response from the server." + mgs << std::endl;
return 1;
}

View File

@@ -3,17 +3,17 @@
std::string cleanup_html(std::string const &encoded_string)
{
size_t start = encoded_string.find("<pre>") + 5;
size_t last = encoded_string.find("</pre>");
int start = encoded_string.find("<pre>") + 5;
int last = encoded_string.find("</pre>");
std::string ret;
ret = encoded_string.substr(start, last - start);
size_t b = 0;
for (size_t a = b; a < ret.length(); a++)
for (int a = b; a < ret.length(); a++)
{
if (ret[a] == '<')
{
for (size_t b = a; b < ret.length(); b++)
for (int b = a; b < ret.length(); b++)
{
if (ret[b] == '>')
{

View File

@@ -55,4 +55,6 @@ std::string ReadFile(const char *filename);
/// @breef Replace in string
std::string Replace(std::string source, std::string from, std::string out);
int NoResponse(std::string mgs);
#endif

View File

@@ -2,7 +2,7 @@ Usage: dm-cli [global] <group> [<args>]
Global options:
--debug print debug information, input and output API requests
--address <ip:port> address of the bitdeals dm, default: 127.0.0.1:4999
--address <ip:port> address of the bitdeals dm, default: https://127.0.0.1:4999
--help print condensed help for all subcommands
--version print version string

View File

@@ -2,7 +2,7 @@
Глобальные параметры:
--debug выводить отладочную информацию, входные и выходные API-запросы
--address <ip:port> адрес модуля сделок (dm), по умолчанию: 127.0.0.1:4999
--address <ip:port> адрес модуля сделок (dm), по умолчанию: https://127.0.0.1:4999
--help вывести краткую справку по всем подкомандам
--version вывести строку версии