2 ms·
> I don't know why you'd analyze the performance impact when you have many failures. If a failure is that common, then you aren't supposed to be using exception
by masklinn 5y ago
> I don't know why you'd analyze the performance impact when you have many failures. If a failure is that common, then you aren't supposed to be using exceptions.
The problem is in that case you get into a probabilistic estimation, which is a nice way to say you roll the dice on your performances: what’s the ratio at which exceptions are too costly or sufficiently cheap? And how does that impact your level of service if e.g. exceptions are extremely rare but they tend to all affect the same request or workload?
- HelloNurse 5y agoIf the program fails too often or too unfairly, why should you blame how such failures are handled? The only reasonable "probabilistic estimation" is that something that happens 10% of the time is normal and it shouldn't be treated as an "exception", even if actually thrown exceptions were fast.
- masklinn 5y ago> If the program fails too often or too unfairly, why should you blame how such failures are handled? Because the discussion is about methods of reporting and handling failure? > The only reasonable "probabilistic estimation" is that something that happens 10% of the time is normal and it shouldn't be treated as an "exception" That makes no sense whatsoever, and doesn't address the question. And even if a ctor fails at a rate of 0.9, it has to report errors via exceptions, because that's the only mechanism available to ctors.
- im3w1l 5y agoYou could use an output pointer parameter. You could construct an object which self-reports as invalid. You could take an error handler callback. You could use a global variable. Or I think my preference would be a private constructor, and a friend-function that returns value-or-error.
- xrikcus 5y agoAdding to that once exceptions start being thrown, that ratio changes because the cost is so high. It's not hard for a service to reach a failure rate just high enough that it overwhelms the system.