aboutsummaryrefslogtreecommitdiff
path: root/include/Result.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/Result.hpp')
-rw-r--r--include/Result.hpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/Result.hpp b/include/Result.hpp
index 316e45a..749d381 100644
--- a/include/Result.hpp
+++ b/include/Result.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <string>
+#include <cassert>
namespace amalgine
{
@@ -28,16 +29,22 @@ namespace amalgine
static Result<T> Err(const Result<OtherType> &otherResult)
{
Result<T> result;
- result.errorMsg = otherResult.errorMsg;
- result.errorCode = otherResult.errorCode;
+ result.errorMsg = otherResult.getErrorMsg();
+ result.errorCode = otherResult.getErrorCode();
return result;
}
bool isOk() const { return errorCode == 0; }
bool isErr() const { return !isOk(); }
operator bool() const { return isOk(); }
+ T& unwrap()
+ {
+ assert(isOk());
+ return data;
+ }
const std::string& getErrorMsg() const { return errorMsg; }
+ int getErrorCode() const { return errorCode; }
private:
Result(){}
private: