When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled. We decouple error identification from error handling. Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation. What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling. Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation. What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation. What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation. What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation. What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation.
What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation.
What do we do on contract violations today?
Ignore reality. Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation.
What do we do on contract violations today?
Ignore reality.
Document. Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation.
What do we do on contract violations today?
Ignore reality.
Document.
Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation.
What do we do on contract violations today?
Ignore reality.
Document.
Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction
Exceptions in use
When afailurehappens, we use exceptions as an error reporting mechanism.
Notify that an error has occurred and needs to be handled.
We decouple error identification from error handling.
Example: Throwingbad_alloc.
When library detects anassumption was not met, it needs a mechanism to react.
Assumption not met⇒contract violation.
What do we do on contract violations today?
Ignore reality.
Document.
Throw exceptions.
Robustnessandcorrectnessare orthogonal properties andshould be managed independently.
Contracts programming for C++20 Introduction