Question: We have a whole bunch of websites with very similar web.config files.

Can you centralise the duplicate configs in 1 config file before the root directory of each website? Or is the only option machine.config?

We are looking to centralise an assembly reference in the GAC.

Structure:

* Containing Directory
	+ Website 1 Directory
	+ Website 2 Directory
	+ Website 3 Directory
	+ Web.Config File for all above sites

Answer: 
The answer above does not apply for Functions that take arguments - for the later case, I think you would want something like this: 

```
def handleError(f):
    def handleProblems(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except Exception:
            print "Oh noes"
    return handleProblems

```

We can test it like so: 

```
@handleError
def addTwo(x, y): 
    print(x + y) 

>>> addTwo(5,5)
10
>>> addTwo(5, 's')
Oh noes 

```
I ran into the same scenario recently, in my case I have some custom exceptions based on which I need to log or raise the Exception further. I have created a decorator method to handle the exceptions as per type.

```
try:
   obj.some_method()
except Exception as e:
    catch_and_log_exception(e)

def catch_and_log_exception(e):
    if isinstance(e, MyConnectionError):
        print "Connection error : %s." % e.message
        sys.exit(1)
    elif isinstance(e, MyConnectionTimeout):
        print "Connection to server has been timed out. %s" % e.message
        sys.exit(1)
    elif isinstance(e, MyException):
        message = e.explanation if e.explanation else e.message
        log_error_message(str(message))
        print "Failed, please check the logs."
        sys.exit(1)
    else:
        raise e

```

Hope this help !!