Change api error structure
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user