SPARK-1907 .value() on failed result should be null instead of an exception that nobody will remember to catch

This commit is contained in:
Eric Harding committed 2018-11-29 14:59:43 -05:00
1 parent d6c1285ada
commit fc5e4039b2
2 files changed
+7 -7

No files matched your search

+6 -1
View File
@@ -37,7 +37,12 @@ namespace bts.api.core
public T value {
get {
if (success) return _result;
else throw new ApiException(error_message);
else {
if (typeof(T).IsValueType) { throw new ApiException(error_message); }
else {
return default(T);// always null
}
}
}
}
public bool success { get { return _code == ApiError.Success; } }
+1 -6
View File
@@ -57,7 +57,7 @@ public:
std::shared_ptr<T> result() const {
if (success()) return _t;
else throw ApiException(std::string(error_message()));
else return nullptr;
}
bool success() const { return _code == ApiError::SUCCESS; }
@@ -66,13 +66,8 @@ public:
const char* error_message() const { return error_string(_code); }
~Result() {}
// Is not a type??
// typedef std::function<void(Result<T>)> OnResponse;
};
//template <typename T>
//using OnResponse = std::function<void(Result<T>)>;
}}//namespace