Question: I went through several discussion, tutorials etc. and I've a feeling like there is no way to inform the user using prototype, that his function might throw an exception.

For instance:

```
/* AudioStream.h */
class AudioStream
{
   int open(struct stream_settings &settings);
}

```

```
/* AudioStream.cpp */
int AudioStream::open(struct stream_settings &settings)
{
    int err;
    err = snd_pcm_open(...);
    if (err < 0)
    {
        /* Throw some exception here */
    }
}

```

If the final product ends up in a library with a header. How does one figures out, that the open function throws an exception and it's necessary to put it into a try/catch block?

Thank you for all the great answers.

Answer: 
Unlike some languages which indicate in the function signature that it "throws", C++ has no such mechanism. This is something you must establish in the documentation or comments near the function definition.
Like already said, you cannot necessarily determine if a function may throw or not. The opposite however, is indeed possible. By declaring a function [`noexcept`](https://en.cppreference.com/w/cpp/language/noexcept_spec) you have the guarantee that this function will never throw an exception that leaves the own function body. However, if a `noexcept` function were to throw anyway without handling the exception in itself, the program will be terminated. So as long as a function isn't declared `noexcept`, and you have no documentation or knowledge about the function, expect that it may throw exceptions.

Another possibility is the use of [error codes](https://en.cppreference.com/w/cpp/error/error_code) or [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional) instead of throwing exceptions.

There is also a [great talk](https://www.youtube.com/watch?v=ARYP83yNAWk) from my man Herb Sutter about exceptions.

And [here](https://godbolt.org/z/VP25aQ) are some examples how you could avoid exceptions in favor of some sort of error codes.