I have several C# methods that I want to wrap in a try-catch block. Each function will have the same logic for the catch. Is there an elegant way to add a decorator to each of these functions so they are all wrapped with the same try/catch block? I don't want to add the try/catch block to all of these functions.
Example:
public void Function1(){
try {
do something
}catch(Exception e) {
//a BUNCH of logic that is the same for all functions
}
}
public void Function2() {
try {
do something different
}catch(Exception e) {
//a BUNCH of logic that is the same for all functions
}
}