﻿# V2673\. MISRA\. An empty throw should only occur within the compound\-statement of a catch handler\.

This diagnostic rule is based on the [MISRA](https://misra.org.uk/) \(Motor Industry Software Reliability Association\) software development guidelines\.

This diagnostic rule is relevant only for C\+\+\.

The analyzer has detected that the `throw` expression has no operand \(rethrowing the active exception\) and is not located inside a `catch` block\. Such code may contain an error\. A `throw;` statement outside the explicit syntactic boundaries of a `catch` handler is a sign of a potential defect\. If the code is executed while there are no active exceptions in the program, the [`std::terminate`](https://timsong-cpp.github.io/cppwp/n4950/except.terminate#1.8) function will be invoked, causing the program to crash\.

The example:

```cpp
try
{
  if (ok)
    return ....;

  throw;
}
catch (...)
{
}
```

In this example, the `throw` expression is executed within the `try` block, where no exception has yet been caught\. Since the exception object for the throw is missing, executing this code results in the `std::terminate` function invocation\.

The fixed code:

```cpp
try
{
  if (ok)
    return ...;

  throw some_exception(....);
}
catch (...)
{
}
```