August 2017
Intermediate to advanced
438 pages
14h 19m
English
When reporting errors or failures, it is more important to report the steps that lead to the error rather than the error itself. Consider the naive trading simulator:
int main() { int money = 1000; start_trading(money);}
All it reports is a line:
Sorry, you're bankrupt!
That's a no go. We want to know how did it happened, what were the steps that led to bankruptcy!
Okay. Let's fix the following function and make it report the steps that led to bankruptcy:
void report_bankruptcy() { std::cout << "Sorry, you're bankrupt!\n"; std::exit(0);}
Read now
Unlock full access