25#ifndef PXR_BASE_TF_EXCEPTION_H
26#define PXR_BASE_TF_EXCEPTION_H
32#include "pxr/base/tf/api.h"
34#include "pxr/base/tf/functionRef.h"
41PXR_NAMESPACE_OPEN_SCOPE
90 out = std::move(_throwStack);
97 virtual const char *
what() const noexcept override;
100 template <class Derived, class ... Args>
102 Tf_Throw(TfCallContext const &cc,
108 static
void _ThrowImpl(TfCallContext const &cc,
111 int skipNCallerFrames);
113 TfCallContext _callContext;
114 std::vector<uintptr_t> _throwStack;
115 std::
string _message;
119template <class Exception, class ... Args>
121Tf_Throw(TfCallContext const &cc,
124 Exception exc(std::forward<Args>(args)...);
125 auto thrower = [&exc]() {
throw std::move(exc); };
126 TfBaseException::_ThrowImpl(cc, exc, thrower, skipFrames.numToSkip);
130template <
class Exception,
class ... Args>
131void Tf_Throw(TfCallContext
const &cc, Args && ... args) {
143#define TF_THROW(Exception, Exception-ctor-args...)
144#define TF_THROW(Exception, TfSkipCallerFrames, Exception-ctor-args...)
148#define TF_THROW(Exception, ...) \
149 Tf_Throw<Exception>(TF_CALL_CONTEXT, __VA_ARGS__)
153PXR_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...