There is no linguistic agnostic answer to this question, but I assume the plugin is a kind of dll.
If you cannot trust the plugin, there are some potential benefits of preventing it. If nothing else helps isolate errors, but also provides the user with some protection against malicious plugins and helps with the reliability and reliability of your application.
However, it is rather difficult to avoid trusting the plugin. Depending on the OS, you are going to run it in your own process with minimal privileges, without access to the file system or sockets, limited access to resources such as memory and processor time, a monitor that will kill it if it turns out to be unresponsive, talking to your process only through a pipe? If not, then some kind of buggy plugin will find a way to ruin your day, which means that you "relied" on your correctness, whether you plan it or not.
Capturing exceptions means you are using the plugin in one of your applications. Therefore, you trust him. You cannot โmake sure that it does not workโ if it has the ability to do some OS-specific thing that causes the kernel to shut down your process with extreme prejudice.
All that has been said - on the specific problem of catching exceptions, callers should catch exceptions if and only if they can do something useful with them.
I would catch them if the plugin does something irrelevant (for example, rendering one of the components of a web page) or let them go if the plugin does something absolutely necessary for the program (for example, if it is a video codec in a command line transcoding program, maybe I will catch the exception and return it after registering the error that โblamesโ the error in the plugin, otherwise I would handle it the same way as any other unforeseen errors in the program).
Steve jessop
source share