Replacing try/except cur & con management to use 'with' + decorator