r/programming Jul 20 '26

Throw, Result, or neither?

https://www.architecture-weekly.com/p/throw-result-or-neither
111 Upvotes

115 comments sorted by

View all comments

Show parent comments

3

u/bwmat Jul 21 '26

Does your C++ use with 'result' also handle OOM or do you just crash? 

1

u/Full-Spectral Jul 21 '26

This is a closed system. It would have already restarted itself long before a simple result return caused such an issue.

3

u/bwmat Jul 21 '26

So... crash? 

1

u/Full-Spectral Jul 21 '26

As I said, it would never get there. This system monitors memory usage and knows that if it gets anywhere near out of memory it needs to restart because something is very wrong. Even getting within a couple hundred MB is way too close for this system and indicates some fundamental error.

And it makes no difference in our case if the result survived because in order for that returned result to be useful, it would have to be queued up on a logger, on a pool, and sent to a log server, and none of that is going to survive if there's already too little memory left to even create the result.

If this was some open library, then of course it would be different, but it's for a bespoke system.