AutosarC++18_10-M15.3.7¶
Where multiple handlers are provided in a single try-catch statement or function-try-block, any ellipsis (catch-all) handler shall occur last
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
If the catch-all handler is found before any other handler, that behaviour will be performed. Any handlers after the catch-all are unreachable code and can never be executed.
Example
void f1 ( )
{
try
{
// ...
}
catch ( int32_t i ) // int handler
{
// Handle int exceptions
}
catch( ... ) // catch-all handler
{
// Handle all other exception types
}
}
void f2 ( )
{
try
{
// ...
}
catch( ... ) // catch-all handler
{
// Handle all exception types
}
catch ( int32_t i ) // Non-compliant – handler will never be called
{
}
}
Note
For legal reasons, this rule’s description is not part of the public documentation.