Closed galdar496 closed 9 years ago
The reasoning behind this is for code readability. Right now in the engine, either true or false is returned for many things. This is alright but doesn't really allow the calling code to make real decisions based on what happened (e.g. it failed but for a specific reason that we might be able to fix). Using an object like this will help with readability as well. Instead of the user saying, "is < 0 a pass or is 0 a pass" or whatever like you have to do with the C standard lib, you can just query they object with IsValid() and if it isn't, the error code can be checked and handled accordingly.
enum class ErrorCode
{
kSuccess = 0,
};
struct Qi::Result
{
public:
bool IsValid() const { errorCode == Qi::kSuccess; }
Qi::ErrorCode errorCode;
};
The ErrorCode enum could probably be made with some sweet X macro stuff but that might complicate things for an end user, have to think about developer ease vs. user ease.
8b94e66f4034b2178b393659b1d0135ccf1f09ad
each module can define its own error codes in some kind of large enum