Added a try-catch-finally function, which takes advantage of c++11's lambda
functions. Also added test cases to make sure it works