diff options
Diffstat (limited to '3rdparty/bx/include/bx/error.h')
-rw-r--r-- | 3rdparty/bx/include/bx/error.h | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/3rdparty/bx/include/bx/error.h b/3rdparty/bx/include/bx/error.h index 1eb220e7be0..a44a3a8d8cb 100644 --- a/3rdparty/bx/include/bx/error.h +++ b/3rdparty/bx/include/bx/error.h @@ -1,6 +1,6 @@ /* - * Copyright 2010-2018 Branimir Karadzic. All rights reserved. - * License: https://github.com/bkaradzic/bx#license-bsd-2-clause + * Copyright 2010-2022 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bx/blob/master/LICENSE */ #ifndef BX_ERROR_H_HEADER_GUARD @@ -8,22 +8,22 @@ #include "string.h" -#define BX_ERROR_SET(_ptr, _result, _msg) \ - BX_MACRO_BLOCK_BEGIN \ - (_ptr)->setError(_result, "" _msg); \ - BX_MACRO_BLOCK_END +#define BX_ERROR_SET(_ptr, _result, _msg) \ + BX_MACRO_BLOCK_BEGIN \ + (_ptr)->setError(_result, "" _msg); \ + BX_MACRO_BLOCK_END -#define BX_ERROR_USE_TEMP_WHEN_NULL(_ptr) \ - const bx::Error tmpError; /* It should not be used directly! */ \ - _ptr = NULL == _ptr ? const_cast<bx::Error*>(&tmpError) : _ptr +#define BX_ERROR_USE_TEMP_WHEN_NULL(_ptr) \ + const bx::Error tmpError; /* It should not be used directly! */ \ + _ptr = NULL == _ptr ? const_cast<bx::Error*>(&tmpError) : _ptr -#define BX_ERROR_SCOPE(_ptr) \ - BX_ERROR_USE_TEMP_WHEN_NULL(_ptr); \ - bx::ErrorScope bxErrorScope(const_cast<bx::Error*>(&tmpError) ) +#define BX_ERROR_SCOPE(_ptr, ...) \ + BX_ERROR_USE_TEMP_WHEN_NULL(_ptr); \ + bx::ErrorScope bxErrorScope(const_cast<bx::Error*>(&tmpError), "" __VA_ARGS__) -#define BX_ERROR_RESULT(_err, _code) \ - BX_STATIC_ASSERT(_code != 0, "ErrorCode 0 is reserved!"); \ - static const bx::ErrorResult _err = { _code } +#define BX_ERROR_RESULT(_err, _code) \ + BX_STATIC_ASSERT(_code != 0, "ErrorCode 0 is reserved!"); \ + static constexpr bx::ErrorResult _err = { _code } namespace bx { @@ -38,7 +38,6 @@ namespace bx { BX_CLASS(Error , NO_COPY - , NO_ASSIGNMENT ); public: @@ -71,23 +70,57 @@ namespace bx uint32_t m_code; }; + /// Do nothing even if error is set. + class ErrorIgnore : public Error + { + public: + /// + operator Error*(); + }; + + /// In debug build assert if error is set. + class ErrorAssert : public Error + { + public: + /// + ~ErrorAssert(); + + /// + operator Error*(); + }; + + /// Exit application if error is set. + class ErrorFatal : public Error + { + public: + /// + ~ErrorFatal(); + + /// + operator Error*(); + }; + /// class ErrorScope { BX_CLASS(ErrorScope + , NO_DEFAULT_CTOR , NO_COPY - , NO_ASSIGNMENT ); public: /// - ErrorScope(Error* _err); + ErrorScope(Error* _err, const StringView& _name); /// ~ErrorScope(); + /// + const StringView& getName() const; + private: Error* m_err; + const StringView m_name; }; } // namespace bx |