49 explicit Exception(
const std::string& message);
52 explicit Exception(
const std::string& message,
58 const std::string& message,
61 virtual const char*
what()
const noexcept
override;
64 std::string m_Message;
77 using BackendUnavailableException::BackendUnavailableException;
164 template <
typename ExceptionType>
169 throw ExceptionType(message);
173 template <
typename ExceptionType>
178 throw ExceptionType();
188 template <
typename ExceptionType,
typename ComparedType>
190 const ComparedType& leftHandSide,
191 const ComparedType& rightHandSide)
193 if (!(leftHandSide == rightHandSide))
195 std::stringstream ss;
196 ss << message <<
" : " << leftHandSide <<
" != " << rightHandSide;
197 throw ExceptionType(ss.str());
203 #define CHECK_LOCATION() armnn::CheckLocation(__func__, __FILE__, __LINE__)
206 #define ARMNN_THROW_MSG_IF_FALSE(_cond, _except, _str) \
207 do { if (!(static_cast<bool>(_cond))) {throw _except(_str);} } while(0)
208 #define ARMNN_THROW_IF_FALSE(_cond, _except) \
209 ARMNN_THROW_MSG_IF_FALSE(_cond, _except, #_cond)
210 #define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str) \
211 ARMNN_THROW_MSG_IF_FALSE(_cond, armnn::InvalidArgumentException, _str)
212 #define ARMNN_THROW_INVALIDARG_IF_FALSE(_cond) \
213 ARMNN_THROW_MSG_IF_FALSE(_cond, armnn::InvalidArgumentException, #_cond)
Class for non-fatal exceptions raised while initialising a backend.
Base class for all ArmNN exceptions so that users can filter to just those.
virtual const char * what() const noexcept override
Exception(const std::string &message)
Copyright (c) 2021 ARM Limited and Contributors.
void ConditionalThrow(bool condition, const std::string &message)
void ConditionalThrowIfNotEqual(const std::string &message, const ComparedType &leftHandSide, const ComparedType &rightHandSide)
ComparedType must support: operator==(const ComparedType&) operator<<(ostream&, const ComparedType&)
std::string AsString() const
CheckLocation(const char *func, const char *file, unsigned int line)
std::string FileLine() const