HomePhabricator

test: don't throw from the destructor of DebugLogHelper

Description

test: don't throw from the destructor of DebugLogHelper

Summary:

Throwing an exception from the destructor of a class is a bad practice because the destructor will be called when an object of that type is alive on the stack and another exception is thrown, which will result in "exception during the exception". This would terminate the program without any messages.

Instead print the message to the standard error output and call std::abort().

Backport of core#33388.

Depends on D18886.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D18887

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Dec 23 2022, 09:03
FabienCommitted on Thu, Nov 6, 09:47
FabienPushed on Thu, Nov 6, 09:47
Reviewer
Restricted Project
Differential Revision
D18887: test: don't throw from the destructor of DebugLogHelper
Parents
rABCf1f3f1b879cc: log: rate limiting followups
Branches
Unknown
Tags
Unknown