8#ifndef PXR_BASE_TF_EXCEPTION_H
9#define PXR_BASE_TF_EXCEPTION_H
15#include "pxr/base/tf/api.h"
17#include "pxr/base/tf/functionRef.h"
24PXR_NAMESPACE_OPEN_SCOPE
73 out = std::move(_throwStack);
80 virtual const char *
what() const noexcept override;
83 template <class Derived, class ... Args>
85 Tf_Throw(TfCallContext const &cc,
91 static
void _ThrowImpl(TfCallContext const &cc,
94 int skipNCallerFrames);
96 TfCallContext _callContext;
97 std::vector<uintptr_t> _throwStack;
102template <class Exception, class ... Args>
104Tf_Throw(TfCallContext const &cc,
107 Exception exc(std::forward<Args>(args)...);
108 auto thrower = [&exc]() {
throw std::move(exc); };
109 TfBaseException::_ThrowImpl(cc, exc, thrower, skipFrames.numToSkip);
113template <
class Exception,
class ... Args>
114void Tf_Throw(TfCallContext
const &cc, Args && ... args) {
126#define TF_THROW(Exception, Exception-ctor-args...)
127#define TF_THROW(Exception, TfSkipCallerFrames, Exception-ctor-args...)
131#define TF_THROW(Exception, ...) \
132 Tf_Throw<Exception>(TF_CALL_CONTEXT, __VA_ARGS__)
136PXR_NAMESPACE_CLOSE_SCOPE
Functions for recording call locations.
The base class for exceptions supported by the Tf exceptions facilities.
void MoveThrowStackTo(std::vector< uintptr_t > &out)
Move the stack frame pointers from the throw point to out.
TF_API TfBaseException(std::string const &message)
Construct with message, reported by this class's what() implementation.
virtual TF_API const char * what() const noexcept override
Override std::exception::what() to return the message passed during construction.
TfCallContext const & GetThrowContext() const
Return the call context from the throw point associated with this exception.
std::vector< uintptr_t > const & GetThrowStack() const
Return the stack frame pointers from the throw point.
This class provides a non-owning reference to a type-erased callable object with a specified signatur...
This structure is used to indicate that some number of caller frames should be skipped when capturing...