Sujet : Re: encapsulating directory operations
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 07. Jun 2025, 22:12:23
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <10229vo$3b858$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 07.06.2025 21:22, Bonita Montero wrote:
Am 07.06.2025 um 20:43 schrieb wij:
The basic problem of throwing error is losing error context, [...]
Nonsense.
The context doesn't matter. A bad_alloc doesn't need context, a
system_error also not. And that's most of the exceptions the C++
runtime throws (some are derived from system_error).
Context, in the general case, matters. It's been decades that I
used C++, but back then in the 1990's we did pass error context
with the thrown error object. That's an inherent part of C++'s
exception handling. If you use standard error classes without
context that's of course possible, but nothing prevents you to
define yet another error class derived from some existing error
class with additional information. You are actually free to do
what suits you and your projects best; use rudimentary handling,
or have a sophisticated error framework, or anything in between.
Janis