Last active
March 18, 2019 10:30
-
-
Save wi7a1ian/2af517334ef060990752f9e1fbb8e75a to your computer and use it in GitHub Desktop.
Basic return codes defined for C++ API #cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Result | |
{ | |
// failure codes are here and are negative numbers | |
ERROR_UNEXPECTED = -100000, | |
ERROR_MEMORY, // i.e: not enough memory to continue execution | |
ERROR_MEMORY_BAD_CAST, // dynamic cast has failed | |
ERROR_MEMORY_BAD_ALLOC, // could not allocate memory on selected heap | |
ERROR_STACKOVERFLOW, // a stack has overflowed | |
ERROR_ARGUMENT_INVALID, // an argument to a method was invalid | |
ERROR_ARGUMENT_OUT_OF_RANGE, // argument value is out of range | |
ERROR_ARGUMENT_FORMAT, // the format of an argument is wrong | |
ERROR_ARITHMETIC, // over or underflow has occured | |
ERROR_ARITHMETIC_DIVIDEBYZERO, // an attempt was made to divide by zero | |
ERROR_INDEX_OUT_OF_RANGE, // an array index is out of range in internal computation | |
ERROR_IO, // IO operation has failed (generic) | |
ERROR_IO_READ, // IO read has failed | |
ERROR_IO_WRITE, // IO write has failed | |
ERROR_IO_NOT_FOUND, // file (or dir or stream or pipe etc.) not found | |
ERROR_INVALID_OPERATI0N, // a method was called at an invalid time | |
ERROR_INVALID_API_VERSION, // requested and supported API versions do not match | |
ERROR_ACCESS_VIOLATION, // authentication or authorization failure | |
ERROR_CANCELLATION, // cancellation was requested | |
ERROR_OPERATION_TIMEOUT, // the time interval allotted to an operation has expired | |
ERROR_ENUMERATOR, // an enumaration failed (generic) | |
ERROR_ITEM_NOT_FOUND, // requested item could not be found | |
ERROR_UNSUPPORTED, // indicates that an operation is not supported and callr should bail | |
ERROR_STRUCTURE, // parsing structures failed | |
// other error codes go here as needed... | |
SUCCESS = 0, | |
// other success codes go here as needed... | |
WARNING = 10000, | |
WARNING_NO_MORE_ITEMS, // no more items available (enumerator) | |
WARNING_UNSUPPORTED, // indicates that an operation is currently not supported | |
WARNING_NOT_IMPLEMENTED, // indicates that method is not implemented by a class | |
WARNING_STRUCTURE, // soft fail when parsing structures | |
// other warning codes go here as needed... | |
}; | |
inline bool Success(Result result){ return Result::SUCCESS <= result && result < Result::WARNING; } | |
inline bool Failure(Result result) { return result < Result::SUCCESS; } | |
inline bool Warning(Result result) { return result > Result::WARNING; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment