>>They are defined by the runtime condition they represent.
>Exactly. Exceptions represent conditions that violate the rules of the computing environment, while bugs represent conditions that violate “business” rules.
You just moved the goalposts. In real systems the rules are one stack of contracts: language rules, library rules, service rules, business rules. A violation at any layer is a bug relative to that layer’s contract. Many exceptions are thrown for business rules as a matter of design.
Examples:
• ArgumentNullException when a domain service requires a nonempty customer id
• IllegalStateException when a workflow step is called out of order
• ValidationException on a failed business invariant
These are not violations of the CPU. They are domain failures surfaced as exceptions by choice. Your split collapses the second we leave toy examples.
⸻
>>Saying exceptions often announce bugs is perfectly coherent
>Not really. If it were coherent we wouldn’t be here.
This is rhetoric, not a rebuttal. The production fact is simple. When an unhandled exception takes down a request and that outcome violates the service contract, that incident is triaged as a bug. If it is handled and stays within the contract, it is routine control flow. Teams do this every day without metaphysics.
⸻
>But perhaps what you are grasping to say is that it is possible that a bug could “corrupt” the computing environment, which could then also lead to an exception later on?
No need to reach for corruption. Ordinary causal chains are enough.
Bad input passes validation when the spec says it must not. That is a bug. Later division by that input throws. The exception is the observable manifestation of the earlier bug. One cause. One effect. No magic.
If your design instead clamps zero or returns a sentinel, then the exception would be the bug. The label follows the spec, not your taxonomy.
⸻
>Allowing user input of “0” where the business rules say that “0” input is invalid would be considered a bug, and later when that 0 input is used as a divisor would see an exception … The exception in this case would likely reveal that there is also a bug in the user input.
You have just restated that exceptions announce bugs. Your own example concedes the point you claimed was incoherent. The exception is how the system made the hidden violation visible. That is exactly what observability is for.
⸻
>But that does not imply that exceptions encompass bugs. Those are independent events, both wanting their own independent resolutions.
Independent events would mean no causal relation. Yet your own scenario shows a direct chain from the validation bug to the later exception. They are linked by cause and effect and are handled together in a single incident. Ops does not file two unrelated tickets and pretend the crash and the root cause are strangers.
⸻
The correct model is simple and general:
• A spec defines allowed states at every layer.
• A bug is entry into a disallowed state relative to that spec.
• An exception is a mechanism that signals some disallowed states.
From this it follows:
• Many bugs surface as exceptions.
• Some exceptions are not bugs because the spec expects and handles them.
• Some bugs do not raise exceptions because the language or code does not signal them.
Your attempt to split computing environment rules from business rules ignores that both are contracts, and violations of either are bugs. Your own examples demonstrate the causal link you say does not exist.
Nope. This carries the exact same semantic intent as my original comment. I've had to severely dumb down the phrasing over the course of discussion as it is clear you don't have a firm grasp on computing, and may continue to dumb it down even more if you continue to display that you don't understand, but there is nowhere for the goalposts to go. They were firmly set long before my time and cannot be moved.
> and violations of either are bugs.
They are both programmer error. "Bug" and "exception" are different labels we use to offer more refinement in exactly what kind of error was made. If I erroneously write code that operates on a null pointer, contrary to the rules of the computing environment, I created an exception. If I erroneously wrote code to paint a widget blue when the business people intended it to be red, I created a bug. While you may not understand the value in differentiating — to the user who only sees that the program isn't functioning correctly it is all the same, right? — programmers who work on projects in industry do, hence why they created different words for different conditions.
> the language or code does not signal them.
It seems you continue to confuse the exception data structure with exception as a categorical type of programmer error. The discussion is, was, and will only ever be about the later. There was no mention of programming languages at the onset of our discussion and turning us towards that is off-topic. You seem to be here in good faith, so let's keep it that way by staying true to the original topic.
> If I erroneously try to operate on a null pointer, I created an exception.
This is only true if some library/framework you use creates an exception for you.
Why do you operate on a null pointer in the first place? Well, you didn't because you painted something in the wrong color, but because you passed a null pointer to a piece of code, which should not have received a null pointer.
> This is only true if some library/framework you use creates an exception for you.
No. That's like saying you can't have errors unless you language/library/framework has an error datatype. Quite possibly the stupidest thing I've ever heard. A language doesn't need exception data structures or exception handlers for a programmer to violate a rule of the computing environment.
So the language/library/framework does not create an exception when operating on the null pointer, but instead it does not do anything (when it should change the color of a widget from blue to red).
Now you have a bug by operating on a null pointer, which supposedly is an exception, while exceptions cannot be bugs?
> So the language/library/framework does not create an exception when operating on the null pointer
It creates an exception in concept. It might not create an exception data structure, depending on the particulars of the language/library/framework. Which are you referring to when you say "exception" here?
It is a bit unfortunate that we've come to use "exception" to mean different things in different contexts. They are not dependent, though. Just as you can have an error in concept without an error data structure, you can have an exception in concept without an exception data structure.
> It creates an exception in concept. It might not create an exception data structure, depending on the language/library/framework. Which are you referring to when you say exception here?
it creates an exception (your concept), but no exception (data structure)
>Exactly. Exceptions represent conditions that violate the rules of the computing environment, while bugs represent conditions that violate “business” rules.
You just moved the goalposts. In real systems the rules are one stack of contracts: language rules, library rules, service rules, business rules. A violation at any layer is a bug relative to that layer’s contract. Many exceptions are thrown for business rules as a matter of design. Examples:
These are not violations of the CPU. They are domain failures surfaced as exceptions by choice. Your split collapses the second we leave toy examples.⸻
>>Saying exceptions often announce bugs is perfectly coherent >Not really. If it were coherent we wouldn’t be here.
This is rhetoric, not a rebuttal. The production fact is simple. When an unhandled exception takes down a request and that outcome violates the service contract, that incident is triaged as a bug. If it is handled and stays within the contract, it is routine control flow. Teams do this every day without metaphysics.
⸻
>But perhaps what you are grasping to say is that it is possible that a bug could “corrupt” the computing environment, which could then also lead to an exception later on?
No need to reach for corruption. Ordinary causal chains are enough. Bad input passes validation when the spec says it must not. That is a bug. Later division by that input throws. The exception is the observable manifestation of the earlier bug. One cause. One effect. No magic. If your design instead clamps zero or returns a sentinel, then the exception would be the bug. The label follows the spec, not your taxonomy.
⸻
>Allowing user input of “0” where the business rules say that “0” input is invalid would be considered a bug, and later when that 0 input is used as a divisor would see an exception … The exception in this case would likely reveal that there is also a bug in the user input.
You have just restated that exceptions announce bugs. Your own example concedes the point you claimed was incoherent. The exception is how the system made the hidden violation visible. That is exactly what observability is for.
⸻
>But that does not imply that exceptions encompass bugs. Those are independent events, both wanting their own independent resolutions.
Independent events would mean no causal relation. Yet your own scenario shows a direct chain from the validation bug to the later exception. They are linked by cause and effect and are handled together in a single incident. Ops does not file two unrelated tickets and pretend the crash and the root cause are strangers.
⸻
The correct model is simple and general:
From this it follows: Your attempt to split computing environment rules from business rules ignores that both are contracts, and violations of either are bugs. Your own examples demonstrate the causal link you say does not exist.