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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With