Why exceptions for error handling is so important

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 11 02:48:29 PST 2015


Over the last few days, I have been getting weird errors from various programs I 
run on Windows 7. Programs would just fail, or produce corrupt output (I'm 
looking at you, Windows Moviemaker).

I have a 128Gb SSD drive for my system drive, for speed, and a 4T secondary 
spinning drive for storage. I knew I was getting nearly out of space on the SSD 
drive, and had a 256Gb SSD drive ready to swap in.

To migrate the system to the new disk, the idea was to use Windows 
Backup/Restore of the image. Unfortunately, Windows Backup would get a ways 
through the process, then fail with no message beyond an error code. Googling 
the error code produced a vast number of results, and various schemes for fixing 
it, some official, some not. None of them were applicable. Many involved loading 
new drivers, editting the system registry, and all sort of unappealing "solutions".

Then I thought, hmm, maybe it's running out of space for temporary files.

I deleted a few gigs, tried again, and it worked fine! I transferred to the new 
disk, had lots of free gigs, and suddenly the various programs that were 
experiencing mysterious failures all started working properly.

What I'm pretty sure is happening is those programs use error codes for error 
reporting, and then don't check the error codes. This is common practice for C 
code. I'm a little surprised that with Windows' long history, it still has 
problems detecting when it runs out of disk space.

However, if exceptions are thrown for errors instead, the programmer has to 
deliberately add code if he wishes to ignore the error.


More information about the Digitalmars-d mailing list