1234567891011121314151617181920212223242526272829303132333435363738 |
- #ifndef CORE_ERROR_HPP
- #define CORE_ERROR_HPP
- namespace Core {
- enum class Error {
- NONE = 0,
- NEGATIVE_ARGUMENT,
- CAPACITY_REACHED,
- BLOCKED_STDOUT,
- OUT_OF_MEMORY,
- INVALID_CHAR,
- NOT_FOUND,
- INVALID_STATE,
- INVALID_INDEX,
- INVALID_ARGUMENT,
- TIME_NOT_AVAILABLE,
- SLEEP_INTERRUPTED,
- THREAD_ERROR,
- EXISTING_KEY,
- CANNOT_OPEN_FILE,
- END_OF_FILE
- };
- const char* getErrorName(Error e);
- inline bool checkError(Error& storage, Error e) {
- return (storage = e) != Error::NONE;
- }
- #define CORE_RETURN_ERROR(checked) \
- { \
- Core::Error error = Core::Error::NONE; \
- if(checkError(error, checked)) [[unlikely]] { \
- return error; \
- } \
- }
- }
- #endif
|