If we refer to exceptions as bugs, why not just call it a bug in the first place instead of an exception?If in the code it's called exception and as soon as it occurs it's called a bug. Then why not call it a bug in the first place?Thank you for any answer or comment.
Why not use the word bug instead of exception?
bug;debugging;issue tracking;exceptions;exception handling
Well, it's pretty simple: not all exceptions are bugs (and similarly, not all bugs manifest themselves as exceptions).As example of an exception that's not a bug, if you're reading a file from a USB drive and someone yanks the drive out of the socket. That's going to raise an exception (in most languages that support exceptions, that is). But it's not a bug in the code.Conversely, a bug might manifest itself as a calculation error or something. You still get an answer, it's just not the right one.Having said that, an exception that makes its way all the way to the top of the stack likely is a bug. In my USB example above, you should be able to catch that exception and present a nice error to the user saying We couldn't read from the file because it's no longer connected. or something. If you just present them with an IOException and some funky error code, then that's a bug. But the exception itself is not.