Date: Tue, 25 May 2021 17:04:32 +0300
пт, 21 мая 2021 г. в 23:41, Kilian Henneberger via Std-Proposals
<std-proposals_at_[hidden]>:
>
> Hi,
> you propose following function:
>
> static basic_stacktrace from_current_exception(const allocator_type& alloc = allocator_type()) noexcept;
>
> I am wondering, if there should then also be a function like this:
>
> static basic_stacktrace from_exception(std::exception_ptr p, const allocator_type& alloc = allocator_type()) noexcept;
>
> Such that you are not only able to query the stacktrace from the current exception, but from any exception that was thrown in the past.
This could be done, however I need some use case examples for that.
I've only faced cases when the stacktrace is printed near the what()
usage of an exception. And that could be done only via rethrowing an
exception:
void handle_eptr(std::exception_ptr eptr) {
try {
std::rethrow_exception(eptr);
} catch(const std::exception& e) {
std::cout << "Caught exception \"" << e.what() << "\"\n" <<
std::stacktrace::from_current_exception();
}
}
<std-proposals_at_[hidden]>:
>
> Hi,
> you propose following function:
>
> static basic_stacktrace from_current_exception(const allocator_type& alloc = allocator_type()) noexcept;
>
> I am wondering, if there should then also be a function like this:
>
> static basic_stacktrace from_exception(std::exception_ptr p, const allocator_type& alloc = allocator_type()) noexcept;
>
> Such that you are not only able to query the stacktrace from the current exception, but from any exception that was thrown in the past.
This could be done, however I need some use case examples for that.
I've only faced cases when the stacktrace is printed near the what()
usage of an exception. And that could be done only via rethrowing an
exception:
void handle_eptr(std::exception_ptr eptr) {
try {
std::rethrow_exception(eptr);
} catch(const std::exception& e) {
std::cout << "Caught exception \"" << e.what() << "\"\n" <<
std::stacktrace::from_current_exception();
}
}
-- Best regards, Antony Polukhin
Received on 2021-05-25 09:04:46