1
0

Change api error structure

This commit is contained in:
Scott E. Graves
2017-03-30 12:44:48 -05:00
parent 69415bcf45
commit 5bc42b1fd4
8 changed files with 127 additions and 95 deletions

View File

@@ -98,6 +98,36 @@ get_access:\
set_access:\
type Set##name(const type& value) { json_doc[#name] = value; return value; }
template<typename T>
class CSiaError
{
public:
CSiaError()
{
SetCode(T::Success);
}
CSiaError(const T& t)
{
SetCode(t);
}
CSiaError(const T& code, const SString& reason)
{
SetCode(code);
SetReason(reason);
}
public:
Property(T, Code, public, private)
Property(SString, Reason, public, private)
public:
operator bool() { return GetCode() == T::Success; }
operator bool() const { return GetCode() == T::Success; }
CSiaError& operator=(const T& code) { SetCode(code); return *this; }
};
typedef struct
{
SString HostName;
@@ -107,7 +137,7 @@ typedef struct
template<typename T>
inline bool ApiSuccess(const T& t) {
return t == T::Success;
return static_cast<bool>(t);
}
typedef ttmath::UInt<256> Hastings;